我的Docker学习笔记
2015-09-13 21:05
621 查看
Docker学习资料:官方:http://docs.docker.com/userguide/中文:http://yeasy.gitbooks.io/docker_practice/content/introduction/what.html一、Ubuntu下安装docker安装教程:http://docs.docker.com/installation/#installation系统安装好后vi /etc/environment追加下面两行export http_proxy="http://172.17.18.84:8080"export https_proxy="https://172.17.18.84:8080"保存sudo apt-get install docker.io(等待执行完成,装完后网络会因冲突中断)sudo service docker.io stopip link del docker0 (网络恢复)vim /etc/default/docker.io追加下面两行DOCKER_OPTS="--bip=10.0.42.1/20"export http_proxy="http://172.17.18.84:8080"保存sudo service docker.io start————————————————————————————————————————————————————安装nsenterdocker run --rm -v /usr/local/bin:/target jpetazzo/nsenter验证安装是否成功which nsenterwhich docker-enter—————————————————————————————————————————————————————二、Docker基本操作例如:
sudo docker run ...
$ sudo docker stop insane_babbageCommands:attach Attach to a running containerbuild Build an image from a Dockerfilecommit Create a new image from a container's changescp Copy files/folders from the containers filesystem to the host pathdiff Inspect changes on a container's filesystemevents Get real time events from the serverexport Stream the contents of a container as a tar archivehistory Show the history of an imageimages List imagesimport Create a new filesystem image from the contents of a tarballinfo Display system-wide informationinspect Return low-level information on a containerkill Kill a running containerload Load an image from a tar archivelogin Register or Login to the docker registry serverlogs Fetch the logs of a containerport Lookup the public-facing port which is NAT-ed to PRIVATE_PORTpause Pause all processes within a containerps List containerspull Pull an image or a repository from the docker registry serverpush Push an image or a repository to the docker registry serverrestart Restart a running containerrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save an image to a tar archivesearch Search for an image in the docker indexstart Start a stopped containerstop Stop a running containertag Tag an image into a repositorytop Lookup the running processes of a containerunpause Unpause a paused containerversion Show the docker version informationwait Block until a container stops, then print its exit code1、保持bash运行容器
The
assigns a pseudo-tty or terminal inside our new container and the
allows us to make an interactive connection by grabbing the standard in (
of the container.退出:
停止容器$ sudo docker stop insane_babbage查看指令的帮助:例如:$ sudo docker attach --help命令详细说明和例子:
http://docs.docker.com/reference/commandline/cli/
sudo docker run ...
$ sudo docker stop insane_babbageCommands:attach Attach to a running containerbuild Build an image from a Dockerfilecommit Create a new image from a container's changescp Copy files/folders from the containers filesystem to the host pathdiff Inspect changes on a container's filesystemevents Get real time events from the serverexport Stream the contents of a container as a tar archivehistory Show the history of an imageimages List imagesimport Create a new filesystem image from the contents of a tarballinfo Display system-wide informationinspect Return low-level information on a containerkill Kill a running containerload Load an image from a tar archivelogin Register or Login to the docker registry serverlogs Fetch the logs of a containerport Lookup the public-facing port which is NAT-ed to PRIVATE_PORTpause Pause all processes within a containerps List containerspull Pull an image or a repository from the docker registry serverpush Push an image or a repository to the docker registry serverrestart Restart a running containerrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save an image to a tar archivesearch Search for an image in the docker indexstart Start a stopped containerstop Stop a running containertag Tag an image into a repositorytop Lookup the running processes of a containerunpause Unpause a paused containerversion Show the docker version informationwait Block until a container stops, then print its exit code1、保持bash运行容器
$ sudo docker run -t -i ubuntu:14.04 /bin/bash
The
-tflag
assigns a pseudo-tty or terminal inside our new container and the
-iflag
allows us to make an interactive connection by grabbing the standard in (
STDIN)
of the container.退出:
root@af8bae53bdd3:/# exit
2、以守护进程运行
A Daemonized Hello world $ sudo docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done" $ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1e5535038e28 ubuntu:14.04 /bin/sh -c 'while tr 2 minutes ago Up 1 minute insane_babbage$ sudo docker ps -l
查看输出
$ sudo docker logs insane_babbage
停止容器$ sudo docker stop insane_babbage查看指令的帮助:例如:$ sudo docker attach --help命令详细说明和例子:
http://docs.docker.com/reference/commandline/cli/
相关文章推荐
- 容易centos配置docker维修
- Docker 根本不适合用于本地开发环境
- 2. docker-compose
- docker中批量删除 tag为none的镜像
- docker 创建容器 时的 注意事项
- docker安装注意事项
- 整合 Jenkins 和 Docker
- Docker 的应用场景在哪里?
- 十大基于Docker的开发工具
- docker中如何制作自己的基础镜像
- Python 开发者的 Docker 之旅
- 在Linux系统下使用Docker以及Weave搭建Nginx反向代理
- CentOS 7 x64 Codis 群集 以及 单机 docker
- Docker常用命令
- 3.0.4、认识docker架构
- 解决Docker build时 Sending build context to Docker daemon 过大的问题
- 【Howie玩docker】-docker安装
- 香蕉派 banana pi BPI-R1 Docker 环境中运行8个LINUX系统
- Use vagrant Ubuntu docker environment
- 安装docker时遇到的问题汇总