查询Docker container运行状态:
# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
发现docker没有启动,使用如下命令启动docker服务:
[root@okqvd ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@okqvd ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
查询docker信息:
[root@okqvd ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.09.6
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.14.4.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.5 (Maipo)
OSType: linux
Architecture: x86_64
CPUs: 52
Total Memory: 149.5GiB
Name: hz-build-cloud-cbts02-okqvd.novalocal
ID: IVEY:IY4R:WWLW:4WQO:FTWJ:5LBB:EVJP:YGFX:DFI4:A3PS:F3QO:Q7JK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
用dockerfile创建镜像:
docker build -t docker-registry.eecloud.net/alice/hellowdockerfile .
docker build -t docker-registry.eecloud.net/alice:hellowdockerfile .
获取image:
docker login -u user_name archive.docker-registry.eecloud.net
docker pull archive.docker-registry.eecloud.nsn-net.net/xxxserver:v2.4
创建image tag:
docker tag imageid repo_name:tag
# docker tag 0ddbef699e25 repo_:1.0.0
# docker push repo:1.0.0
创建容器:
docker run docker-registry.eecloud.net/alice:hellowdockerfile /bin/sh -c "while true;do echo hello world;sleep 1;done"
docker run -t -i docker-registry.eecloud.net/alice:hellowdockerfile /bin/bash
docker run -d docker-registry.eecloud.net/alice:hellowdockerfile /bin/sh -c "while true;do echo hello world;sleep 1;done" 守护态运行(-d参数)
启动容器:
docker start 启动已经停止的容器
进入容器:
docker attach 80ff07a0d82e
docker exec -it container_id /bin/bash
查看容器:
docker ps 列出运行的容器
docker ps -a 列出所有容器,包括已经停止的
停止容器:
docker stop container_id
删除容器:
docker rm container_id
获取容器的输出信息:
docker logs 936
重启容器:
docker restart
推送Image到远程仓库:
docker build archive.docker-registry.net/NAMESPACE/IMAGE_NAME
docker login -u user_name archive.docker-registry.net
docker push archive.docker-registry.net/NAMESPACE/IMAGE_NAME
docker 入门到实践: https://yeasy.gitbooks.io/docker_practice/content/