docker環境部署

參考官方鏈接:https://docs.docker.com/install/linux/docker-ce/centos/

初始化:

1、關閉selinux

2、如果你的數控盤不再根目錄,比如在 /data目錄,可以通過軟鏈接的方式,將docker的images和container目錄切過去

[root@QA-es-kafka ~]# mkdir /data/docker -p
[root@QA-es-kafka ~]# ln -s /data/docker/ /var/lib/docker
[root@QA-es-kafka ~]#

3、修改內核參數 /etc/sysctl.conf

vm.max_map_count=262144

net.ipv4.ip_forward = 1

sysctl -p #讓配置生效

開始安裝docker

Uninstall old versions
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.

$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
It’s OK if yum reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce.

SET UP THE REPOSITORY
Install required packages. 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
Use the following command to set up the stable repository. You always need the stablerepository, even if you want to install builds from the edge or test repositories as well.

$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
INSTALL DOCKER CE
Install the latest version of Docker CE, or go to the next step to install a specific version:

$ sudo yum install docker-ce
If prompted to accept the GPG key, verify that the fingerprint matches060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it.

Got multiple Docker repositories?

If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install or yum update command always installs the highest possible version, which may not be appropriate for your stability needs.

Docker is installed but not started. The docker group is created, but no users are added to the group.

To install a specific version of Docker CE, list the available versions in the repo, then select and install:

a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:

$ yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64 18.09.0.ce-1.el7.centos docker-ce-stable
The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the .el7 suffix in this example).

b. Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-), for example, docker-ce-18.03.0.ce.

$ sudo yum install docker-ce-<VERSION STRING>
Docker is installed but not started. The docker group is created, but no users are added to the group.

Start Docker.

$ sudo systemctl start docker
Verify that docker is installed correctly by running the hello-world image.

$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章