docker 容器新建

先查看ubuntu 镜像版本:
a)sudo docker search ubuntu

结果:

wxsc@ubuntu:/usr/include/x86_64-linux-gnu/bits$ sudo docker search ubuntu
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                 Ubuntu is a Debian-based Linux operating sys…   9102                [OK]                
dorowu/ubuntu-desktop-lxde-vnc                         Ubuntu with openssh-server and NoVNC            263                                     [OK]
rastasheep/ubuntu-sshd                                 Dockerized SSH service, built on top of offi…   198                                     [OK]
consol/ubuntu-xfce-vnc                                 Ubuntu container with "headless" VNC session…   152                                     [OK]
ubuntu-upstart                                         Upstart is an event-based replacement for th…   96                  [OK]                
ansible/ubuntu14.04-ansible                            Ubuntu 14.04 LTS with ansible                   95                                      [OK]
neurodebian                                            NeuroDebian provides neuroscience research s…   56                  [OK]                
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          48                                      [OK]
ubuntu-debootstrap                                     debootstrap --variant=minbase --components=m…   40                  [OK]                
nuagebec/ubuntu                                        Simple always updated Ubuntu docker images w…   23                                      [OK]
tutum/ubuntu                                           Simple Ubuntu docker images with SSH access     18                                      
i386/ubuntu                                            Ubuntu is a Debian-based Linux operating sys…   16                                      
1and1internet/ubuntu-16-apache-php-7.0                 ubuntu-16-apache-php-7.0                        13                                      [OK]
ppc64le/ubuntu                                         Ubuntu is a Debian-based Linux operating sys…   12          


下载需要的镜像
b)sudo docker pull ubuntu
查看下载好的镜像
c)sudo docker images
结果:

wxsc@ubuntu:/usr/include/x86_64-linux-gnu/bits$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              20bb25d32758        4 hours ago         87.5MB
ubuntu_530          1.0                 42f2e5f5b4a5        2 weeks ago         1.44GB


image id为:20bb25d32758 既是刚刚pull 的
创建容器:docker run 其实是 Run a command in a new container
d)sudo docker run -dit 20bb25d32758
查看所有的容器:
e)sudo docker container ls -a
结果:

wxsc@ubuntu:/usr/include/x86_64-linux-gnu/bits$ sudo docker container ls -a
CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS                      PORTS               NAMES
28d5656eddc4        20bb25d32758            "/bin/bash"         7 minutes ago       Up 7 minutes                                    vigilant_liskov
e0e164289853        ubuntu_530:1.0          "/bin/bash"         2 weeks ago         Exited (255) 30 hours ago                       ubuntu_530

给新建容器重命名:
f)sudo docker rename vigilant_liskov spec2006

进入容器
g)sudo docker exec -it spec2006 "/bin/bash"

猜你喜欢

转载自blog.csdn.net/z278718149/article/details/86606262
今日推荐