浏览文章
文章信息
CentOS7 Linux环境下Docker安装
16329
一、环境准备
系统准备
(1)系统控制System Control中关闭并禁用firewalld
systemstl stop firewalld
systemctl disable firewalld
(2)SElinux禁用
cat /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted确保SELINUX=disabled
1、依赖安装
安装所需的软件包。
yum-utils
提供了yum-config-manager
效用,并device-mapper-persistent-data
和lvm2
由需要devicemapper
存储驱动程序。yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
2、设置源
使用以下命令来设置稳定的存储库。
yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
3、可选操作
此操作针对环境中可能存在禁用docker源的解操作,一般不会。
启用:
yum-config-manager --enable docker-ce-nightly禁用:
yum-config-manager --disable docker-ce-nightly
二、安装
一般选择社区版即可。
社区版:
yum install docker-ce docker-ce-cli containerd.io企业版:
yum install docker-ee docker-ce-cli containerd.io
三、启动Docker
# 启动
systemstl start docker
# 验证
docker run hello-world
看到以下输出说明已经安装完成
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064 Status: Downloaded newer image for hello-world:latest 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/
最后:如果以上步骤繁琐,使用一键安装。