[Docker] docker installation in VMware CentOS7

Install docker on CentOS 7

1. Check the version, kernel version and bit of centOS system
cat /etc/centos-release
uname -r
getconf LONG_BIT


2. Uninstall the installed docker
yum remove docker docker-common container-selinux docker-selinux docker-engine


3. Install docker CE version
1). Install required packages yum-utils, device-mapper-persistent-data, lvm2
yum-utils provides yum-config-manager utility
device-mapper-persistent-data and lvm2 are Required for devicemapper storage driver
$ yum install -y yum-utils device-mapper-persistent-data lvm2
2). Set stable repository
$ yum-config-manager --add-repo https://download.docker.com /linux/centos/docker-ce.repo

3. Optional: Edge repository configuration
This repository is included in the docker.repo file above, but disabled by default. You can enable it next to the stable repository.
$ yum-config-manager --enable docker-ce-edge
You can disable edge storage by running the yum-config-manager command with the --disable flag --disable . 
To re-enable it, use the --enable flag. The following command disables the edge repository.
$ yum-config-manager --disable docker-ce-edge

4. Update the yum package index
$ yum makecache fast
5. Install the latest version of Docker
$ yum install docker-ce
On production systems, you should install a specific version of Docker instead of always using the latest version.

 

5. Edit /etc/docker/daemon.json file
{
    "storage-driver":"devicemapper"
}

6. 启动docker
$service docker start

$systemctl start docker


7. Set to automatically start
$chkconfig docker on
or
$systemctl enable docker.service

8. How to use the Docker accelerator For
users with Docker client version greater than 1.10,
you can use the accelerator by modifying the daemon configuration file /etc/docker/daemon.json:
$mkdir -p /etc/docker
s
$vim /etc/docker/
Add the following content to daemon.json :
{
 
  "registry-mirrors": ["https://w5z91a3d.mirror.aliyuncs.com"]
}
}

$systemctl daemon-reload
s
$systemctl restart docker

9. Download the official CentOS image
$docker pull centos


10. View the downloaded CentOS docker image
$docker images centos


11. Run the docker run command to test whether the installation is successful
$docker run hello-world
or
$docker run centos echo 'Hello World'
The result shows an error:
docker: Error response from daemon: OCI runtime create failed: unable to retrieve OCI runtime error.. .

12. Uninstall docker using the command in step 2
$yum remove docker docker-common container-selinux docker-selinux docker-engine
Check if device-mapper is installed
$ls -l /sys/class/misc/device-mapper

This machine has been installed. If it is not installed, use the following command to install device-mapper
$yum install -y device-mapper


13. Restart docker and set it to verify correctness after the system starts

yum install -y lxc-docker


This machine has been installed. If it is not installed, use the following command to install device-mapper
$service docker start
$chkconfig docker on
$docker pull centos
$docker images centos
$docker run centos echo 'Hello World'


Successful installation

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325239056&siteId=291194637