1, Docker sudo-free execution
// create a group
sudo groupadd docker
// add the current user to the docker group
sudo gpasswd -a ${USER} docker
// restart the docker service
sudo service docker restart
//3. Switch sessionsNewgrp -docker The groups command obtains cached group information and the newly added group information does not take effect. Therefore, switch the current session to the new groupCopy the code
2. How to execute the host docker command from inside the container
docker run -it -d \
--restart=always -u root \
-v /usr/bin/docker:/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/lib64/libltdl.so7.:/usr/lib/x86_64-linux-gnu/libltdl.so7. ImageName
Copy the code
Libltdl-so.7 is a library that Docker command execution depends on. If the host does not have it, it will be created automatically when the above command is executed.
3. Mirror acceleration
(1) Obtain accelerator address
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
Copy the code
(2) Configure the local Docker
#1. Create a daemon.json file
vim /etc/docker/daemon.json
#2. Add the following information to the file{"registry-mirrors": ["https:// your accelerator address. Mirror.aliyuncs.com "]}#3. Restart
systemctl daemon-reload
#4. Restart the docker
systemctl restart docker
Copy the code