1. 程式人生 > >centos 7 docker測試

centos 7 docker測試

root nds HA http api DC 1.9 oca IT

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
yum list docker-ce --showduplicates | sort -r
systemctl
systemctl start docker
docker version
systemctl enable docker

docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:20:16 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

docker run centos echo ‘hello world‘
Unable to find image ‘centos:latest‘ locally
latest: Pulling from library/centos
469cfcc7a4b3: Pull complete
Digest: sha256:989b936d56b1ace20ddf855a301741e52abca38286382cba7f44443210e96d16
Status: Downloaded newer image for centos:latest
hello world

docker run centos echo ‘hello world‘


hello world

docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest e934aafc2206 6 weeks ago 199MB

docker run -i -t --name=centos2 centos /bin/bash #用鏡像centos6創建容器,設置名稱為centos2
[root@8be75c0a6f52 /]#

docker start centos2 以守護形式啟動容器


centos2

docker ps 查看正在運行的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f115f1e1b40 centos "/bin/bash" 9 minutes ago Up 8 seconds centos3


[root@izwz98hlt9fisw6uu80b46z ~]# docker attach centos2 進入容器

docker ps -a 查看所有容器

docker inspect centos2

docker run -i -t --name=centos3 centos /bin/bash

docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f115f1e1b40 centos "/bin/bash" 50 seconds ago Exited (127) 10 seconds ago centos3
8be75c0a6f52 centos "/bin/bash" 14 minutes ago Exited (0) 9 minutes ago centos2
3099b0fdc926 centos "/bin/bash" 19 minutes ago Exited (0) 3 minutes ago angry_bassi
f9b3f780da23 centos "echo ‘hello world‘" 25 minutes ago Exited (0) 25 minutes ago pedantic_stonebraker
66d0e7b547b4 centos "echo ‘hello world‘" 25 minutes ago Exited (0) 25 minutes ago silly_brahma

centos 7 docker測試