在云服务器上体验Docker
1. 添加Docker repository key
sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
2. 添加Docker repository,并安装Docker
sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
apt-get update
apt-get install lxc-docker
3. 检查Docker是否已安装成功
docker version
基本使用
1.安装 ubuntu 镜像
docker pull ubuntu
开始下载 ubuntu 镜像, 大概需要10分钟左右
Pulling repository ubuntu
9cbaf023786c: Pulling dependent layers
a9561eb1b190: Pulling dependent layers
195eb90b5349: Pulling dependent layers
2185fd50e2ca: Pulling dependent layers
c5881f11ded9: Pulling dependent layers
463ff6be4238: Pulling dependent layers
3db9c44f4520: Pulling dependent layers
511136ea3c5a: Download complete
500cae81e00f: Downloading [=========================================> ] 58.63 MB/70.36 MB 1m6s
查看一下当前的镜像列表
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.10 2185fd50e2ca 2 days ago 237.2 MB
ubuntu utopic 2185fd50e2ca 2 days ago 237.2 MB
ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB
ubuntu 14.04.1 9cbaf023786c 2 days ago 192.8 MB
ubuntu trusty 9cbaf023786c 2 days ago 192.8 MB
ubuntu latest 9cbaf023786c 2 days ago 192.8 MB
ubuntu 12.04.5 a9561eb1b190 2 days ago 120.2 MB
ubuntu precise a9561eb1b190 2 days ago 120.2 MB
ubuntu 12.04 a9561eb1b190 2 days ago 120.2 MB
ubuntu 12.10 c5881f11ded9 3 months ago 172.2 MB
ubuntu quantal c5881f11ded9 3 months ago 172.2 MB
ubuntu 13.04 463ff6be4238 3 months ago 169.4 MB
ubuntu raring 463ff6be4238 3 months ago 169.4 MB
ubuntu saucy 195eb90b5349 3 months ago 184.7 MB
ubuntu 13.10 195eb90b5349 3 months ago 184.7 MB
ubuntu 10.04 3db9c44f4520 5 months ago 183 MB
ubuntu lucid 3db9c44f4520 5 months ago 183 MB
执行一个命令
docker run ubuntu:12.10 ls -lh /
total 68K
drwxr-xr-x 2 root root 4.0K Oct 16 2012 bin
drwxr-xr-x 2 root root 4.0K Oct 9 2012 boot
drwxr-xr-x 4 root root 340 Oct 16 15:51 dev
drwxr-xr-x 44 root root 4.0K Oct 16 15:51 etc
drwxr-xr-x 2 root root 4.0K Oct 9 2012 home
drwxr-xr-x 11 root root 4.0K Oct 16 2012 lib
drwxr-xr-x 2 root root 4.0K Oct 16 2012 lib64
drwxr-xr-x 2 root root 4.0K Oct 16 2012 media
drwxr-xr-x 2 root root 4.0K Oct 9 2012 mnt
drwxr-xr-x 2 root root 4.0K Oct 16 2012 opt
dr-xr-xr-x 128 root root 0 Oct 16 15:51 proc
drwx------ 2 root root 4.0K Oct 16 2012 root
drwxr-xr-x 5 root root 4.0K Oct 16 2012 run
drwxr-xr-x 2 root root 4.0K Jun 18 21:54 sbin
drwxr-xr-x 2 root root 4.0K Jun 11 2012 selinux
drwxr-xr-x 2 root root 4.0K Oct 16 2012 srv
dr-xr-xr-x 13 root root 0 Oct 16 15:51 sys
drwxrwxrwt 2 root root 4.0K Oct 16 2012 tmp
drwxr-xr-x 11 root root 4.0K Oct 16 2012 usr
drwxr-xr-x 14 root root 4.0K Oct 16 2012 var
2.登录到 docker 里面去
docker run -i -t ubuntu:12.10 /bin/bash
root@bb55c85e1b34:/# uname -a
Linux bb55c85e1b34 3.5.0-52-generic #78~precise1-Ubuntu SMP Wed Jun 11 17:14:53 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
root@bb55c85e1b34:/# ip addr
25: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
26: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 12:6d:9c:14:76:82 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.9/16 scope global eth0
inet6 fe80::106d:9cff:fe14:7682/64 scope link
valid_lft forever preferred_lft forever
3.安装 openssh-server
ubuntu 默认的源在腾讯云主机上无法访问, 所以要把源改成腾讯云的源, 登录到 docker 里面去发现里面连 vi 编辑器都没有, 没办法, 只能把主机的文件映射到 docker 里面去, 然后 cp
下面的命令把主机的 /etc 映射到 docker 的/opt/etc
目录, 并且运行 bash
docker run -i -t -v /etc:/opt/etc ubuntu:12.10 /bin/bash
进入 docker 后把主机的 sources.list 文件 copy 过去, 在 docker 里面执行下面的命令
cp /etc/apt/sources.list /etc/apt/sources.list.bak
cp /opt/etc/apt/sources.list /etc/apt/sources.list
然后再执行 apt 命令安装就没有问题了
apt-get install -y vim openssh-server
设置个 ROOT 密码
root@fc9fe30c21bc:/# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
查看下 docker 的ip
root@fc9fe30c21bc:/# ip addr
43: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
44: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether e2:b9:5a:f8:d5:a1 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.15/16 scope global eth0
inet6 fe80::e0b9:5aff:fef8:d5a1/64 scope link
valid_lft forever preferred_lft forever
启动 ssh
root@7e3adf35663f:/# /etc/init.d/ssh restart
从主机上登录
ssh root@172.17.0.15
The authenticity of host '172.17.0.15 (172.17.0.15)' can't be established.
ECDSA key fingerprint is cf:19:d7:73:02:7e:58:90:08:79:8c:f0:85:2c:a2:9e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.17.0.15' (ECDSA) to the list of known hosts.
root@172.17.0.15's password:
Welcome to Ubuntu 12.10 (GNU/Linux 3.5.0-52-generic x86_64)
* Documentation: https://help.ubuntu.com/
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
root@fc9fe30c21bc:~#
4.保存对docker的修改
查看下 CONTAINER ID
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc9fe30c21bc ubuntu:12.10 "/bin/bash" 11 minutes ago Up 11 minutes evil_turing
保存 上一步的 CONTAINER ID 是 fc9fe30c21bc 但是不用全部输入只要保证不重复就可以了
docker commit fc9f y109/ubuntu
e099241dfc1fb31d950b0be4de2fa7a78510022737fe8cc81a913bdd4a244a95
确认 镜像列表里面有刚刚保存的镜像
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
y109/ubuntu latest e099241dfc1f 14 seconds ago 316.2 MB
ubuntu 14.10 2185fd50e2ca 2 days ago 237.2 MB
ubuntu utopic 2185fd50e2ca 2 days ago 237.2 MB
ubuntu trusty 9cbaf023786c 2 days ago 192.8 MB
ubuntu 14.04.1 9cbaf023786c 2 days ago 192.8 MB
ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB
ubuntu latest 9cbaf023786c 2 days ago 192.8 MB
ubuntu 12.04 a9561eb1b190 2 days ago 120.2 MB
ubuntu 12.04.5 a9561eb1b190 2 days ago 120.2 MB
ubuntu precise a9561eb1b190 2 days ago 120.2 MB
ubuntu quantal c5881f11ded9 3 months ago 172.2 MB
ubuntu 12.10 c5881f11ded9 3 months ago 172.2 MB
ubuntu raring 463ff6be4238 3 months ago 169.4 MB
ubuntu 13.04 463ff6be4238 3 months ago 169.4 MB
ubuntu 13.10 195eb90b5349 3 months ago 184.7 MB
ubuntu saucy 195eb90b5349 3 months ago 184.7 MB
ubuntu 10.04 3db9c44f4520 5 months ago 183 MB
ubuntu lucid 3db9c44f4520 5 months ago 183 MB
提交
docker push y109/ubuntu
The push refers to a repository [y109/ubuntu] (len: 1)
Sending image list
首次提交会要求登录
Please login prior to push:
Username: y109
Password:
Email: y109@qq.com
Login Succeeded
The push refers to a repository [y109/ubuntu] (len: 1)
Sending image list
Pushing repository y109/ubuntu (1 tags)
511136ea3c5a: Image already pushed, skipping
bac448df371d: Image already pushed, skipping
dfaad36d8984: Image already pushed, skipping
5796a7edb16b: Image already pushed, skipping
c5881f11ded9: Image already pushed, skipping
e099241dfc1f: Pushing [===========> ] 32.94 MB/147.3 MB 1m10s
e099241dfc1f: Image successfully pushed- 本文实验环境:腾讯云服务器,ubuntu系统。
在云服务器上体验Docker的更多相关文章
- 在腾讯云服务器上体验Docker
版权声明:本文由姚俊刚原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/85 来源:腾云阁 https://www.qclou ...
- 云服务器上利用Docker部署Django项目
转载别人的,请看下面链接 云服务器上利用Docker部署Django项目
- 阿里云服务器上通过Docker部署redmine
背景:在日常工作的过程中会遇到各种各样的问题,每个问题来了之后需要花时间解决.这里就面临两个问题. 1:问题责任不明确,有时候会遇到数据库或者物理服务器的问题,这时候就需要把相应问题指派给相应的人,传 ...
- 在腾讯CentOS7.4云服务器上安装Docker,在Docker上安装配置MySQL、Tomcat和Nginx
提示:以下是在腾讯CentOS7.4云服务器上操作. Docker的基本操作:https://www.cnblogs.com/opsprobe/p/10963098.html 一.安装Docker # ...
- 如何在云服务器上使用Docker部署easy-mock
部署Easy-mock 安装Docker Ubuntu下安装Docker 安装Docker-compose Ubuntu下安装docker-compose 使用Docker部署 Easy-Mock D ...
- 阿里云服务器上在docker部署jenkins
1.查询jenkins:docker search jenkins 2.拉取jenkins镜像 docker pull jenkins/jenkins:lts 3.新建jenkins的工作目录: mk ...
- 在Ubuntu14.04系统POWER8服务器上搭建Docker Registry服务
本文描述了如何在POWER8服务器上搭建一个本地化的Docker镜像仓库,主要涉及镜像制作,Docker Registry服务启动等.希望能够对在非X86服务器上搭建Docker仓库的同学提供参考. ...
- 阿里云服务器上安装mysql的心路历程(博友们进来看看哦)
在阿里云花了100买了一台云服务器,配置如下: CPU: 1核 内存: 512MB 数据盘: 0G 带宽: 1Mbps 阿里云服务器安装mysql搞得我想吐血,搞了一个多星期,现在才搞好,而且,还有许 ...
- 阿里云服务器上使用iptables设置安全策略
转自:http://www.netingcn.com/aliyun-iptables.html 公司的产品一直运行在云服务器上,从而有幸接触过aws的ec2,盛大的云服务器,最近准备有使用阿里云的弹性 ...
随机推荐
- 浏览器指纹--纯js拿到浏览器指纹
序言: 前两天有接收到一下问题,如何拿到浏览器指纹中的位置信息和CPU,在这之前完全没有接触过浏览器指纹,抱着学习和好奇的心态,就去网上查了大量的资料.下面我将学习过程和成果贴出来给大家. 步骤 1. ...
- 1、html(),text(),value()的区别;2、remove() 3、加载完执行函数
1 .html()用为读取和修改元素的HTML标签.2 .text()用来读取或修改元素的纯文本内容.3 .val()用来读取或修改表单元素的value值. 这三个方法功能上的对比 .html() ...
- js判断是pc还是移动端
//判断pc还是移动端 var isM = function () { var ua = navigator.userAgent; /* navigator.userAgent 浏览器发送的用户代理标 ...
- SQL授权语句(MySQL基本语句)
看他们网上的,写得都是千篇一律,同时,好多也写得不是很好,下面是我自己总结的有关mysql的使用细节,也是我在学习过程中的一些记录吧,希望对你有点帮助,后面有关存储过程等相关操作还没有总结好,下次总结 ...
- jsp:forEach标签
该标签使用来对一个 Collection 集合中的一系列对象进行迭代输出,并且可以指定迭代次数.一般使用格式如下: <c:forEach items=”collection” var=”varN ...
- 目标检测 — 计算IOU
1.IOU=交集/并集 #include<iostream> #include<algorithm> #include<stdio.h> #include < ...
- python直接赋值,浅拷贝和深拷贝
本文参考自<Python 直接赋值.浅拷贝和深度拷贝解析> 定义 直接赋值:就是对象的引用(别名) 浅拷贝(copy):拷贝父对象,不拷贝对象内部的子对象 深拷贝(deepcopy):co ...
- 剑指offer--8.调整数组顺序使奇数位于偶数前面
习惯了简单 ------------------------------------------------- 时间限制:1秒 空间限制:32768K 热度指数:422906 本题知识点: 数组 题目 ...
- HDU - 5307 :He is Flying (分治+FFT)(非正解)
JRY wants to drag racing along a long road. There are nn sections on the road, the ii-th section has ...
- redis 双写一致性问题
首先,缓存由于其高并发和高性能的特性,已经在项目中被广泛使用.在读取缓存方面,大家没啥疑问,都是按照下图的流程来进行业务操作. 但是在更新缓存方面,对于更新完数据库,是更新缓存呢,还是删除缓存.又或者 ...