Docker系列 1 安装
安装
SET UP THE REPOSITORY
相关包
yum-utils
provides the yum-config-manager
utility, and device-mapper-persistent-data
and lvm2
are required by the devicemapper
storage driver
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
set up the stable repository
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum-config-manager --disable docker-ce-edge
官方文档,路径错误
INSTALL DOCKER CE
sudo yum install docker-ce
On production systems, you should install a specific version of Docker CE instead of always using the latest.
yum list docker-ce --showduplicates | sort -r
sudo yum install <FULLY-QUALIFIED-PACKAGE-NAME>
Start Docker
sudo systemctl start docker
sudo systemctl enable docker
Verify
sudo docker run hello-world
基本命令
sudo docker search centos # ubuntu, fedora
sudo docker pull centos
sudo docker pull httpd
# check if docker images downloaded
sudo docker images centos
# run docker
sudo docker run -i -t centos /bin/bash
sudo docker run -d -p 80:80 httpd
# current running list
sudo docker ps
命令过程
docker run -d -p 80:80 httpd
其过程可以简单的描述为:
- 从 Docker Hub 下载 httpd 镜像。镜像中已经安装好了 Apache HTTP Server。
- 启动 httpd 容器,并将容器的 80 端口映射到 host 的 80 端口。
- 下面我们可以通过浏览器验证容器是否正常工作。在浏览器中输入 http://[your ubuntu host IP]
Uninstall Docker CE
Uninstall the Docker package
sudo yum remove docker-ce
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
sudo rm -rf /var/lib/docker