docker入门教程
来源:互联网 发布:linux thrift源码安装 编辑:程序博客网 时间:2024/05/20 13:13
环境是virtualbox中安装了Ubuntu 16,目的在Ubuntu环境下安装使用docker。步骤来源为http://www.docker.org.cn/book/docker/what-is-docker-16.html。
1.安装docker
#sudo apt-get install docker-io
2.查看docker版本
#docker version
Client:
Version:1.12.6
API version:1.24
Go version:go1.6.2
Git commit:78d1802
Built: TueJan 31 23:35:14 2017
OS/Arch:linux/amd64
3.查询可用的docker
#sudo docker search tutorial
NAME DESCRIPTION
learn/tutorial This is the backend of react comment
4.下载容器镜像
#docker pull learn/tutorial
Using default tag: latest
Latest: Pulling from learn/tutorial
271134aeb542: pull complete
Digest: xxxxxxxxxxxxx
Stutas: Downloaded newer image forlearn/tutorial:lastest
5.在docker容器中运行hello world
#sudo docker run learn/tutorial echo “hello world”
补充:在docker容器中运行bash
#sudo docker run –t –I learn/tutorial
Ok
6.在docker容器中安装软件
#docker run learn/tutorial apt-get –y install
报错:
Docker: Cannot connect to the Docker daemon. Is thedocker daemon running on this host?
原因:权限问题,从0.5.2开始docker的守护进程总是以root用户来运行,从0.5.3开始docker创建一个名为docker组,然后将用户加入这个组内。
解决方案
1.使用root权限运行
#sudo docker run learn/tutorial apt-get –y installping
或者
#su
#systemctl restart docker
#docker run learn/tutorial apt-get –y install ping
2.将当前用户加到docker用户组中
#gpasswd liudongwei docker
7.保存对容器的修改
查看运行的容器
# docker ps –l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
C24e7d6b72aa learn/tutorial “apt-get –yinstall p” 11 seconds ago Exited(0) 2 second ago zen_bratin
# docker commit C24e7d6b72aa learn/ping
Sha256:227bb5dc805a33f1eac6f8ae4557bdb763dd2f0671a72fa95c3a87186c91eec
8.运行新的镜像
# docker run learn/ping ping www.baidu.com
Ok
9.检查运行中的镜像
# sudo docker inspect
得到json字符串
10.发布自己的镜像
#sudo docker push learn/ping
- Docker 入门教程
- Docker入门教程
- docker入门教程
- Docker入门教程
- Docker 入门教程
- docker入门教程
- docker 入门教程
- Docker教程(一) Docker入门教程
- Day 21:Docker 入门教程
- Day 21:Docker 入门教程
- Day 21:Docker 入门教程
- Docker Swarm入门教程
- Docker 入门教程(一)
- Docker 入门教程(二)
- Docker 入门教程(三)
- Docker 入门教程(四)
- Docker 入门教程(五)
- Docker 入门教程(六)
- Java中的方法以及方法重载
- 深度学习笔记---梯度消失、梯度激增
- Python勇冠排行榜首,名企大咖教你免费学
- web测试和app测试重点
- TOJ 3516.Game of Stones
- docker入门教程
- js循环
- 菜鸟笔记--软件测试--百盒测试技术
- python3 GUI 开发 (1)环境配置
- POJ 1273 Drainage Ditches(最大流入门)
- HDU-4686 Arc of Dream(推公式+矩阵快速幂)
- 2017/7/30
- 九、Java中变量的使用规则
- pandas官方文档中cookbook(3)的selection&new column&multiindexing翻译