CentOs8にdockerをインストール

centos8にdockerをインストールする手順です。色々、面倒だったのでメモ
CentOs8バージョン
#cat /etc/centos-release
CentOS Linux release 8.0.1905 (Core)
リポジトリ追加
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## rootで作業 su ## リポジトリを追加する dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ## 確認 dnf repolist <出力結果> repo id repo の名前 AppStream CentOS-8 - AppStream BaseOS CentOS-8 - Base docker-ce-stable Docker CE Stable - x86_64 |
インストール
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
## インストール dnf -y install docker-ce <出力結果> エラー: 問題: package docker-ce-3:19.03.3-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed - cannot install the best candidate for the job - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded - package containerd.io-1.2.2-3.el7.x86_64 is excluded - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages) ## 言われたとおりに--nobestオプションを追加してインストールしてみる dnf install --nobest docker-ce ## 確認 docker --version Docker version 18.06.3-ce, build d7080c1 ## 起動と自動起動設定 systemctl enable docker systemctl start docker |
無事インストールが完了
Nginxを動かしてみる
dockerを利用してNginxを起動してみる
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## port 8080を使用 docker run --name testnginx -d -p 8080:80 nginx <出力結果> Unable to find image 'nginx:latest' locally latest: Pulling from library/nginx b8f262c62ec6: Pull complete e9218e8f93b1: Pull complete 7acba7289aa3: Pull complete Digest: sha256:aeded0f2a861747f43a01cf1018cf9efe2bdd02afd57d2b11fcc7fcadc16ccd1 Status: Downloaded newer image for nginx:latest 08a5fcd2fa825afbb49a1cee2cf4f331cfd1b08a8802a2dc8107dbf154f7101d |
docker runオプション
–name: 任意のイメージ名
-d: デタッチモード コンテナをバックグラウンドで実行
-p ホスト内のポート番号を指定:コンテナ内のポート番号指定
Curlコマンドを利用してアクセスしてみる
curlコマンドは、HTTPリクエストを行い、結果を標準出力することができる
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
## アクセスしてみる curl http://localhost:8080 <出力結果> <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> |
-
前の記事
CentOs8 pythonインストール 2019.10.16
-
次の記事
CentOs8にDocker Composeをインストール 2019.10.16
コメントを書く