安裝Docker和下載images鏡像和經常使用Docker命令

個人是centos7,也會6的方法:linux

$sudo yum install docker   直接yum安裝contos7
使用centos6.5先獲取epel源並
啓動Docker,並註冊開機服務
[root@iZ258c9w799Z ~]# sudo service docker start
Redirecting to /bin/systemctl start  docker.service
[root@iZ258c9w799Z ~]# sudo chkconfig docker on
Note: Forwarding request to 'systemctl enable docker.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
//查看是否啓動

[root@iZ258c9w799Z ~]# ps -ef|grep docker
root 12584 1 0 11:33 ? 00:00:00 /bin/sh -c /usr/bin/docker-current daemon $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY 2>&1 | /usr/bin/forward-journald -tag docker
root 12585 12584 0 11:33 ? 00:00:00 /usr/bin/docker-current daemon --selinux-enabled
root 12586 12584 0 11:33 ? 00:00:00 /usr/bin/forward-journald -tag docker
root 12705 12448 0 11:34 pts/0 00:00:00 grep --color=auto dockerdocker

下載images鏡像,如今下載基礎的contos鏡像:centos

[root@iZ258c9w799Z ~]# sudo docker pull centos:7
Trying to pull repository docker.io/library/centos ... 7: Pulling from library/centos
1544084fad81: Pull complete 
df0fc3863fbc: Pull complete 
a3d54b467fad: Pull complete 
a65193109361: Pull complete 
Digest: sha256:a9237ff42b09cc6f610bab60a36df913ef326178a92f3b61631331867178f982
Status: Downloaded newer image for docker.io/centos:7

查看是否安裝成功:bash

[root@iZ258c9w799Z ~]# sudo docker images centos
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/centos    7                   a65193109361        2 weeks ago         196.7 MB

能夠去docker下載你須要的鏡像:https://hub.docker.com/centos7

經常使用docker命令:spa

1、docker -h 幫助
2、獲取鏡像
sudo docker pull NAME[:TAG]
sudo docker pull centos:latest
3、啓動Container盒子
sudo docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
sudp docker run -t -i contos /bin/bash
4、查看鏡像列表,列出本地的全部images
sudo docker images [OPTIONS] [NAME]
sudo docker images centos
5、查看容器列表,可看到咱們建立過的全部container
sudo docker ps [OPTIONS]
sudo docker ps -a
6、刪除鏡像,從本地刪除一個已經下載的鏡像
sudo docker rmi IMAGE [IMAGE...]
sudo docker rmi centos:latest
7、移除一個或多個容器實例
sudo docker rm [OPTIONS] CONTAINER [CONTAINER...]
移除全部微運行的容器
sudo docker rm sudo docker ps -aq
8、中止一個正在運行的容器
sudo docker kill [OPTIONS] CONTAINER [CONTAINNER...]
sudo docker kill 026e
9、重啓一個正在運行的容器
sudo docker restart [OPTIONS] contains[CONTAINER]
sudo docker restart 026e
10、中止一個已經中止的容器
sudo docker start [OPTIONS] CONTAINER [CONTAINER..]
sudo docker start 026e
 
相關文章
相關標籤/搜索