December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

DOCKER INSTALL CENTOS7

CentOS 7 non-root users install 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 test

cat /etc/passwd | grep dev01

Add sudo permissions for new users

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

  1. Add the current user to the docker group (at this time the user has not joined the 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.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

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

vi /etc/docker/daemon.json

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

systemctl start docker

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 (ie tag)

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

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

into the running container

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

container start / stop / restart / information / 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 all 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 pull -pull images

docker rmi -After deleting the image, you can match it directly based on the image name or the first letter of the tag

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

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

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

docker build -create images using Dockerfile

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

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

Run the container

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

–name container name, followed by mirror path or name

–rm delete the container after running

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

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

-d Contrary to it Hide background run

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>