Docker's installed on Centos

Centos installed on Docker

System Requirements

Docker CE supports 64-bit CentOS 7, and require kernel version is not less than 3.10. CentOS 7 meet the minimum requirements of the kernel, but the kernel version is relatively low, some functions (e.g.,  overlay2 storage layer driver) can not be used, and some functions may be unstable

My system version

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Uninstall the old version

Older versions of Docker called  docker or  docker-engine, use the following command to uninstall the old version

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

Using yum install dependencies

$ sudo yum install -y yum-utils \
           device-mapper-persistent-data \
           lvm2

Add Docker source software

$ sudo yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo


# 官方源
# $ sudo yum-config-manager \
#     --add-repo \
#     https://download.docker.com/linux/centos/docker-ce.repo    

Installation Docker CE

$ sudo yum makecache fast
$ sudo yum install docker-ce

Above is to use yumto install, you can also use automated scripts to install official

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun   # 执行后,docker-ce将安装到系统

Start Docker-ce

$ sudo systemctl enable docker  # 开机启动
$ sudo systemctl start docker   # 启动docker-ce服务

By default, the docker command uses the  Unix socket  and Dockerengine traffic. Only rootusers and dockeruser groups to be able to have rights. It can be the non- rootuser to the dockeruser group

sudo groupadd docker   # 创建docker用户组
sudo usermod -aG docker $USER   # 当前用户加入docker组 

test

After logging retest dockerwhether the service can be used

We now use the docker run hello-worldcommand to start a container, if the hello-worldimage does not exist locally, docker will automatically go to the warehousepull

After running this command, the following log output

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Mirror accelerate

As foreign mirrored pull will be relatively slow, it is recommended to use domestic mirror source

$ vi /etc/docker/daemon.json  # 修改此文件
# 添加如下
{
        "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

$ systemctl restart docker # 重启docker服务

Guess you like

Origin www.cnblogs.com/watertreestar/p/11780272.html