docker
系统环境
lq@lq-OptiPlex-755:~$ uname -a
Linux lq-OptiPlex-755 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
docker需要运行在root用户下,否则有其他问题。。。
安装命令
curl -sSL https://get.docker.com/ | bash -x
这个命令可以查看安装过程,建议先执行下 sudo apt-get update
hello world
root@lq-OptiPlex-755:/home/lq# docker search hello
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
hello-world Hello World! (an exampleDocker... 266 [OK]
tutum/hello-world Image to test docke. Has Apac... 31 [OK]
google/nodejs-hello 15 [OK]
.....
root@lq-OptiPlex-755:/home/lq# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest
root@lq-OptiPlex-755:/home/lq# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 48b5124b2768 7 weeks ago 1.84 kB
root@lq-OptiPlex-755:/home/lq# docker run --name hh 48b5124b2768
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
root@lq-OptiPlex-755:/home/lq# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e0065e063270 48b5124b2768 "/hello" 38 seconds ago Exited (0) 36 seconds ago hh
root@lq-OptiPlex-755:/home/lq# docker rm e0065e063270
e0065e063270
root@lq-OptiPlex-755:/home/lq# docker rmi 48b5124b2768
Untagged: hello-world:latest
Untagged: hello-world@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Deleted: sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233
Deleted: sha256:98c944e98de8d35097100ff70a31083ec57704be0991a92c51700465e4544d08
docker-enter
docker enter用途:
docker容器没起sshd服务的时候,可以使用nsenter进入docker容器。
直接使用nsenter步骤稍微复杂,可以使用docker-enter
安装
wget -P ~ https://github.com/yeasy/docker_practice/raw/master/_local/.bashrc_docker;
. ~/.bashrc_docker
docker-compose
docker compose用途:
Docker Compose属于一个“应用层”的服务,用户可以定义哪个容器组运行哪个应用,它支持动态改变应用,并在需要时扩展。
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
root@lq-OptiPlex-755:/usr/local/bin# docker-compose version
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016
docker-machine
docker machine用途:
Docker的安装流程非常复杂,用户需要登录到相应的主机上,根据官方的安装和配置指南来安装Docker,并且不同的操作系统的安装步骤也是不一样的。而有了Machine后,不管是在笔记本、虚拟机还是公有云实例上,用户仅仅需要一个命令。
curl -L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
chmod +x /tmp/docker-machine &&
sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
root@lq-OptiPlex-755:/usr/local/bin# docker-machine version
docker-machine version 0.10.0, build 76ed2a6