Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to install and configure Docker in Centos7

Shulou Source: shulou.com Published: 2022-06-02 07:05:03 09月17日 Update

I believe many inexperienced people don't know what to do about how to install and configure Docker in Centos7. Therefore, this article summarizes the causes and solutions of the problem. I hope you can solve this problem through this article.

First, install docker

1. View system version

# View linux system version lsb_release-a # installation of docker in CentOS7 requires the system to be 64-bit and the system kernel version 3.10 or above uname-r

2. Install with yum source

The foreign sources brought with CentOS are sometimes very slow, so we replace them with domestic Ali sources.

# Advanced source directory cd / etccd yum.repos.d/

# back up the official source mv CentOS-Base.repo CentOS-Base.repo.bak

# download the Ali source file to wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# rebuild the source data cache yum makecache

Ok, source change completed

# one click to install yum-y install docker

3. Run docker

# check the installation list yum list installed | grep docker

# add it in {} using Docker China Accelerator vi / etc/docker/daemon.json#. After adding: {"registry-mirrors": ["https://registry.docker-cn.com"]," live-restore ": true} # View docker version docker version

# set boot systemctl enable docker

# start dockersystemctl start docker

# View status systemctl status docker

4.dokcer common commands

Docker start container name or container ID-container startup

Docker stop container name or container ID-close the container

Docker pull [options] name [: tag]-pull image, specified version of tag

Docker images-View the list of images

Docker run [options] image [: tag].. -run in the foreground and can be terminated using ctr+c

Docker run-d image-run in the background to print an ID

Docker ps-View running images

Docker exec-it image bash-enter the container

Id / bin/bash of image initiated by docker exec-it

Docker stop $(docker ps-a-Q)-stop all containers

Docker rm $(docker ps-a-Q)-Delete all containers

Systemctl restart docker-docker restart

Docker logs-f-- tail=100-View the last 100 lines of the log

Delete the mirror:

1. First delete the stopped instance

Find stopped instances: docker ps-a

Delete stopped instance: docker rm instance id

two。 Then delete the image in images

View image: docker images

Delete Mirror: docker rmi name

After reading the above, have you mastered how to install and configure Docker in Centos7? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Container image version instance system run configuration content method more problem Ali helpless for this kernel foreground accelerator reason name background Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info Shulou Technology MariaDB MySQL