CentO7.9安裝Docker
刪除舊版本的Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
這個(gè)可能是匹配不到的,來(lái)個(gè)狠一點(diǎn)的
sudo yum remove docker*
帶有Docker的全部刪掉
安裝Docker倉(cāng)庫(kù)
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安裝Docker
安裝最新版本
安裝Docker最新版,不帶版本的默認(rèn)最新版本
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
安裝指定版本
查找docker-ce的版本
[root@WDQCVM ~]# yum list docker-ce --showduplicates | sort -r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:24.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.1-1.el7 docker-ce-stable
查找docker-ce-cli的版本
[root@WDQCVM ~]# yum list docker-ce-cli --showduplicates | sort -r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
* extras: mirrors.aliyun.com
docker-ce-cli.x86_64 1:24.0.5-1.el7 docker-ce-stable
docker-ce-cli.x86_64 1:24.0.5-1.el7 @docker-ce-stable
docker-ce-cli.x86_64 1:24.0.4-1.el7 docker-ce-stable
docker-ce-cli.x86_64 1:24.0.3-1.el7 docker-ce-stable
docker-ce-cli.x86_64 1:24.0.2-1.el7 docker-ce-stable
docker-ce-cli.x86_64 1:24.0.1-1.el7 docker-ce-stable
將參數(shù)替換即可
通用示例
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
指定版本示例
sudo yum install docker-ce-24.0.4-1.el7 docker-ce-cli-24.0.4-1.el7 containerd.io docker-buildx-plugin docker-compose-plugin
Centos7.9版本安裝Docker指定版本時(shí),安裝了好多次這么設(shè)置版本號(hào)才成功,在軟件包名稱(chēng)和版本號(hào)之間不需要添加數(shù)字和冒號(hào),但官網(wǎng)給出的實(shí)例是帶有:
的,費(fèi)解。
校驗(yàn)是否成功
[root@WDQCVM ~]# sudo systemctl start docker
[root@WDQCVM ~]# sudo docker --version
Docker version 24.0.4, build 3713ee1
[root@WDQCVM ~]#
有以下這些就可說(shuō)明成功了文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-653887.html
[root@WDQCVM ~]# sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
[root@WDQCVM ~]#
Docker安裝個(gè)NGINX
[root@WDQCVM ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
52d2b7f179e3: Pull complete
fd9f026c6310: Pull complete
055fa98b4363: Pull complete
96576293dd29: Pull complete
a7c4092be904: Pull complete
e3b6889c8954: Pull complete
da761d9a302b: Pull complete
Digest: sha256:13d22ec63300e16014d4a42aed735207a8b33c223cff19627dd3042e5a10a3a0
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@WDQCVM ~]#
查看Docker鏡像
[root@WDQCVM ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest eea7b3dcba7e 27 hours ago 187MB
hello-world latest 9c7a54a9a43c 3 months ago 13.3kB
運(yùn)行
[root@WDQCVM ~]# docker run --name nginx -p 8080:80 -d nginx
d1b23e05201a232eb57c2458423b88cee5dc9a27464bb680978676dcd4dd741a
[root@WDQCVM ~]#
查看Docker進(jìn)程
[root@WDQCVM ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d1b23e05201a nginx "/docker-entrypoint.…" 7 seconds ago Up 4 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp nginx
[root@WDQCVM ~]#
查看啟動(dòng)端口
[root@WDQCVM ~]# ss -ltnp |grep 8080
LISTEN 0 128 *:8080 *:* users:(("docker-proxy",pid=11654,fd=4))
LISTEN 0 128 [::]:8080 [::]:* users:(("docker-proxy",pid=11661,fd=4))
[root@WDQCVM ~]#
停止Docker容器
[root@WDQCVM ~]# docker stop nginx
nginx
[root@WDQCVM ~]#
[root@WDQCVM ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@WDQCVM ~]#
Docker官網(wǎng)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-653887.html
到了這里,關(guān)于CentO7.9安裝Docker的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!