docker学习

docker作为去年比较火的一款快速部署工具,正好最近闲来无事就去学习饿了下

首先是安装docker


sudo apt-get install apt-transport-https 

 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 

vi /etc/apt/sources.list.d/docker.list
     deb https://apt.dockerproject.org/repo ubuntu-xenial main


sudo apt-get update


sudo apt install lxc-docker

安装完后尝试启动docker

sudo service docker start


在执行docker  info

sudo docker info


Containers: 7
 Running: 0
 Paused: 0
 Stopped: 7
Images: 3
Server Version: 1.12.1
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 18
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host null bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-24-generic
Operating System: Ubuntu 16.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.539 GiB
Name: lkzlr
ID: XQ32:AKBQ:DQFN:E3GQ:BYSC:ZQMZ:KYXZ:7YUF:EOIN:7PO7:2QYC:FRY4
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: lkzlr
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8


若输出如上面列表则安装成功


然后去下载镜像

sudo docker pull ubuntu:14.04

示例下载ubuntu 14.04的镜像


然后运行他

sudo docker run -i -t ubutnu:14.04 /bin/sbin

若要后台运行则加上参数-d


运行后就对他进行配置跟ubuntu 14.04 的配置一致   http://blog.csdn.net/qq_30371793/article/details/50387589


配置完成后退出docker


然后去 hub.docker.com 注册用户登陆并创建库


创建完成后在终端里面登陆docker账号

sudo docker login

并输入账号密码


登陆完成后将镜像加入后台运行

然后去提交容器到自己的docker 库


sudo docker commit 运行时的容器id 账号/库名:tag名

sudo docker push账号/库名:tag名


你可能感兴趣的:(docker学习)