Linux CentOS 7 non-root installations Source version Docker

Note: The non-root user must have sudo privileges

First, pre-installation preparation

1. Review the current host has docker group

If there is no output of the new

Again, the group found to have docker

2. New Users with sudo privileges (root and if they know others have sudo permissions system user password, skip 3; if not, will do)

Modify the user's password

Add sudo permissions for new users

VI the sudo / etc / the sudoers 
  the next line is added 92 
  Test ALL = (ALL) ALL

3. the current user to the docker group (in this case the user is not added into the docker group)

Switch to the sudo user permissions, and then switch back to the current user ( At this point you can see the user has joined the group docker )

3. Delete the new user and it's sudo privileges (step 2 do not ignore this step)

sudo vi /etc/sudoers
  在92行下一行添加
  test  ALL=(ALL)  ALL

Two exits, otherwise an error when deleting users

Two, installation docker

1. Download docker source package and upload it to a virtual machine

https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-18.09.0.tgz

2. Extract the source package to the specified directory

3. The instruction in the extract from the docker copied to the directory / usr / bin / directory

sudo cp docker/* /usr/bin/

docker on the instruction of one owner and group under 4./usr/bin/ directory (must be done, otherwise the non-root user docker instruction error: insufficient privileges)

sudo chown root:docker /usr/bin/docker*
sudo chown root:docker /usr/bin/containerd*
sudo chown root:docker /usr/bin/runc
sudo chown root:docker /usr/bin/ctr

The check whether to change one owner and group (as obtained and the eight instructions in the extract from the docker directory)

6. docker registered as a service service

新建该文件
sudo vi /etc/systemd/system/docker.service
加入以下内容:
[Unit] Description
=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target

7. Add execute permissions and reload the configuration file

sudo chmod a+x /etc/systemd/system/docker.service
sudo systemctl daemon-reloa

8.docker Mirror acceleration (can not do it, but docker pull will be very slow, due to the docker's official website overseas)

The new document 
the sudo VI / etc / Docker / daemon.json
add the following
{
" Registry-Mirrors " : [ " http://hub-mirror.c.163.com " ] }
 

9. Start docker

sudo systemctl start docker

Three, docker basic commands

docker start / stop / restart / view the status 
sudo systemctl start / stop / restart / status

View docker has been mirrored
docker images

in the docker's official website searches for the specified mirror
docker search image

Download image (without labeling the default download the latest version of the image)
docker pull Mirror name: tag (i.e., label)

starting container (xxx name based mirror in a container, the container port and mapped to a local port, the container directory files stored in a local directory)
Docker rUN -d -p -name xxx local port: container port -v local directory: container directory mirroring name: tag (or ID)

into the container inside a running
docker exec -it container name (or ID) / bin / bash

start / stop / restart / information containers / delete
docker start / stop / restart / inspect / rm container name (or ID)

to view the vessel running
docker ps

view all vessels (including running, stop, do not include deleted)
docker ps -a

remove the mirror (mirror before deleting Please delete all associated with the image container)
docker rmi mirrors name: tag (or ID)

to view information about the currently installed docker
docker info

dd

Guess you like

Origin www.linuxidc.com/Linux/2020-01/162075.htm