`
haoningabc
  • 浏览: 1478716 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

docker的helloworld

阅读更多
参考
https://hub.docker.com/
注册帐号,邮箱验证
http://www.widuu.com/chinese_docker/userguide/dockerlinks.html

http://www.cnblogs.com/qlwy/archive/2012/06/04/2535297.html
有些地方需要去访问google
ssh -qTfnN -D 7070 root@52.74.143.66


docker
https://www.rhel.cc/2014/11/50/

.换用CentOS软件源
在rhel7上所用用centos的源
[root@rhel7 ~]# vi /etc/yum.repos.d/CentOS7-Base-163.repo
######
[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

#########


[root@rhel7 ~]#systemctl  start docker
[root@rhel7 ~]#systemctl enable docker

下载一个镜像
docker pull fedora/apache

运行
docker images
docker run -i -t fedora/apache /bin/bash


下面我们把docker虚拟机中的80端口 映射到我们物理机的80端口


[root@rhel7 ~]# docker run -p 192.168.137.100:80:80 -d -i -t fedora/apache /bin/bash
不好用 因为启动的是bash没起apache
进系统看一下有个脚本启动apache

docker run -i -t  fedora/apache /run-apache.sh
curl 172.17.0.2
docker run -d -i -t -p 192.168.139.218:80:80  fedora/apache /run-apache.sh
curl 192.168.139.218

[root@rhel7 ~]# setenforce 0
[root@rhel7 ~]#mkdir /share
[root@rhel7 ~]#touch /share/share_test.txt
[root@rhel7 ~]# docker run -v /share:/share -i -t fedora/apache /bin/bash


docker ps


docker run ubuntu:14.04 /bin/echo 'Hello world'

docker run -t -i ubuntu:14.04 /bin/bash
docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
docker ps
docker logs clever_yonath
docker top trusting_stallman
docker inspect trusting_stallman

docker run -d -p 5000:5000 training/webapp python app.py
docker run -d -P --name web -v /webapp training/webapp python app.py
docker port web 5000
docker logs -f web
docker top web
docker inspect web
docker start web
docker stop web


http://www.jb51.net/article/56051.htm
批量删除
docker kill $(docker ps -a -q)
docker rm $(docker ps -a -q)


docker pull centos

docker run -t -i centos /bin/bash
docker search sinatra

docker pull training/sinatra
docker run -t -i training/sinatra /bin/bash
进去修改任何一个文件
把container id保存成一个和自己用户名一样的另一个镜像
docker commit -m "add hello" -a="killinux" c8f2b9390dd5 killinux/sinatra:v2

docker run -t -i haohao/sinatra:v2 /bin/bash
可以使用Dockerfile
[root@localhost sinatra]# cat Dockerfile 
# This is a comment
FROM ubuntu:14.04
MAINTAINER Kate Smith <ksmith@example.com>
RUN apt-get update && apt-get install -y ruby ruby-dev
RUN gem install sinatra


docker build -t haohao/sinatra:v2 .

docker images haohao/sinatra
打tag
docker tag a3655c5ea034 haohao/sinatra:devel

docker images --digests | head

container id
docker commit -m "add hello" -a="killinux" 979f62ec1411 killinux/sinatra:v3
docker images killinux/sinatra
docker tag 3733e9b4b9f1 killinux/sinatra:devel
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics