docker基本管理

一、docker基本命令

  1.docker 获取镜像

    将从 Docker Hub 仓库下载一个 Ubuntu 12.04 操作系统的镜像

   

docker pull ubuntu:12.04
Pulling repository ubuntu
ab8e2728644c: Pulling dependent layers
511136ea3c5a: Download complete
5f0ffaa9455e: Download complete
a300658979be: Download complete
904483ae0c30: Download complete
ffdaafd1ca50: Download complete
d047ae21eeaf: Download complete

    1.2. 仓库注册服务器下载较慢,可以从其他仓库下载。 从其它仓库下载时需要指定完整的仓库注册服务器地址。

    

$ sudo docker pull dl.dockerpool.com:5000/ubuntu:12.04
Pulling dl.dockerpool.com:5000/ubuntu
ab8e2728644c: Pulling dependent layers
511136ea3c5a: Download complete
5f0ffaa9455e: Download complete
a300658979be: Download complete
904483ae0c30: Download complete
ffdaafd1ca50: Download complete
d047ae21eeaf: Download complete

  1.3创建一个容器,让其中运行 bash 应用

$ sudo docker run -t -i ubuntu:12.04 /bin/bash
root@fe7fc4bd8fc9:/#
View Code

  1.4 Docker 列出镜像

  

root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/ubuntu    12.04               5b117edd0b76        18 months ago       104 MB
View Code

   1.5 Docker 创建镜像

    

1.先使用下载的镜像启动容器。
    docker run -t -i training/sinatra /bin/bash
    root@0b2616b0e5a8:/#
    注意:记住容器的 ID,稍后还会用到。
1.2在容器中添加 json 和 gem 两个应用。
    gem install json
13. 当结束后,我们使用 exit 来退出,现在我们的容器已经被我们改变了,使用 docker commit 命令来提交更新后的副本。
    docker commit -m "Added json gem" -a "Docker test" 4ea44ea59b2c ouruser/sinatra:v2

   1.6存出和载入Docker镜像

 
1.存出镜像
docker save -o ubuntu_14.04.tar ubuntu:14.04

2.载入镜像
     docker load --input ubuntu_14.04.tar
       docker load < ubuntu_14.04.tar

 

posted @ 2018-11-03 16:39  鱼丸粗面没鱼丸  阅读(162)  评论(0编辑  收藏  举报