docker installation and use under CentOS 7

docker start stop

sudo systemctl start docker.service 
sudo systemctl stop docker.service
sudo systemctl restart docker.service 
sudo systemctl status docker.service 
sudo systemctl enable docker

sudo docker ps -a ## <-- List existing images ##
sudo docker stop 17dd4ab4cda2 ##<-- 17dd4ab4cda2 by container id ##
sudo docker rm 17dd4ab4cda2 ##<-- delete container id ##
sudo docker rmi image_name ##<-- delete images ##
sudo docker ps -a | grep Exit | awk '{print $1}' | xargs docker rm ##<-- delete exit Of images ##
docker info  ## <-- confirm Docker Is it installed correctly ##
# docker rm --force `docker ps -qa`

Problems encountered

After the docker is started by cenOS, the virtual machine fails to ping?

The reason is that the docker daemons use as the network segment by default. You can find the network of docker 0 through ifconfig, which conflicts with the network segment of the host;

resolvent: , i.e. add under / etc/docker daemon.json File, modify docker to start the default network segment

Execution_ ifconfig docker0 down _ that will do

ifconfig command

` docker info`

Reuslts in Get http:///var/run/docker.sock/v1.12/info: dial unix /var/run/docker.sock: permission denied


Add docker user group

sudo groupadd docker

Give all users of the user group the rights of docker

sudo usermod -a -G docker $USER

Exit ssh client and log in again

docker installation under cenOS

yum install docker

yum install epel-release

yum install docker-io

systemctl enable docker

systemctl start docker  
systemctl status docker

docker run hello-world

Publish Vue application configuration in Node mode


FROM node:9.11.1-alpine

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory

# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# install project dependencies
RUN npm install

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# build app for production with minification
RUN npm run build

CMD [ "http-server", "dist" ,"-p 8888"]


## start docker
cd frontend/tms
echo "Delete previous container..."
docker rm --force `docker ps -qa`
echo "Generate image..."
docker build -t  tms_frontend:1.0 .
echo "Start container..."
docker run -p 8888:8888 --net=host --rm --name tms_frontend  tms_frontend:1.0  &

Docker compose installation

sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

sudo chmod a+x /usr/local/bin/docker-compose
docker-compose --version

Build docker private service

Open private server port 5000

Use the official registry image to start the local private warehouse

firewall-cmd --zone=public --add-port=5000/tcp --permanent
docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
docker start $(docker ps -l | grep registry | awk '{print $1}') #Start warehouse

If the port is not turned on, there is a connection rejected error when you view the image in the registry in pull image and curl image

Configure private ip address

The docker registry uses https, so when downloading a remote image with the docker pull command, an error will be reported if the remote docker registry is non https

To solve this problem, you need to add startup parameters when starting docker server

Open / etc/docker/daemon.json , add secure registers

After modifying the configuration, execute the following command

systemctl daemon-reload
sudo systemctl restart docker.service

Preparing the mirror

docker pull hello-world
docker tag bf756fb1ae65
docker push
curl -X GET

Keywords: Operation & Maintenance Docker sudo JSON network

Added by Phirus on Thu, 21 May 2020 17:37:51 +0300