Dark Light

CentOS 7 non-root users set up source version of Docker

  1. Check if the current host has a docker group

cat /etc/group | grep docker

sudo groupadd docker

cat /etc/group | grep docker

useradd check

cat /etc/passwd | grep dev01

Add sudo permissions for new users

mire /etc/sudoers
?? Add on line 92 next line
?? dev01 MANY = (ALL) ALL

  1. Add the present user to the docker group (at this time the user has not joined the particular docker group)

gpasswd -a admin docker

https://download.docker.com/linux/static/stable/x86_64/docker-19.03.7.tgz

mkdir /docker

tar -zxvf docker-19. 03. 7. tgz -C /docker

cp docker/* /usr/bin/

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

ll /usr/bin/ | grep docker

vi /etc/systemd/system/docker. service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online. target firewalld. services
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

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

mire /etc/docker/daemon. json

“registry-mirrors”: [“http://hub-mirror.rmohan.com”]

systemctl start docker

docker basic commands

docker start / prevent / restart / view the position
sudo systemctl begin / stop / restart and status

View docker has been mirrored
docker images

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

Download image (without labeling the default download the latest version of the image)
docker pull Mirror Name: tag (ie tag)

Start the container (run the image-based container with the name xxx, and map the container port to the local interface, and the container directory file will be stored in the local directory)

docker operate -d -name xxx -p Nearby port: Container port -v native directory: container directory image name: tag (or ID)

into the running container

docker exec -it pot name (or ID) / bin / bash

container start / stop / restart / info / delete

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

view running containers

docker ps

view all containers (including running, stopped, not including deleted)

docker ps -a

image deletion (before deleting the image Please delete many containers related to this image)

docker rmi image name: tag (or ID)

view information about currently installed docker

docker info

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager –add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum install docker-ce

systemctl enable docker

systemctl start docker

groupadd docker

usermod -aG docker $USER

docker volume create portainer_data

docker run -d -p 9000: 9000 -v /var/run/docker. sock: /var/run/docker. sock -v portainer_data: /data portainer/portainer

Docker common commands
docker ps -view all containers currently running -a display including stopped containers

docker draw -pull images

docker rmi -After removing the image, you can match it straight based on the image name or the initial letter of the tag

docker start container_id- open container (here can be box id or name)

docker stop container_id -stop container (here can be pot id or name)

docker rm -delete a container (only stopped storage containers can be deleted)

docker build -create images using Dockerfile

docker exec -execute instructions in the container, for example: docker professional -it container_id (container name or id) / bin / bash (bin / bash command or even tool to execute)

docker logs –View container logs, for example: docker logs -f -t –tail 10 container_id (container name or id)

Operate the container

docker run -it –rm -p 8000: 80 –name aspnet_sample microsoft/dotnet__

–name container name, followed by reflect path or name

–rm delete the particular container after running

-p interface mapping 8000 external port eighty mirroring running port mapping 8000 to 80 mirroring

-it outputs the particular contents of the container command line, that is, the container’s own plan output is a bit similar to the foreground run in the console

-d Contrary to it Hide background run

Leave a Reply

Your email address will not be published. Required fields are marked *