WORKDIR /root/gopath/src/BringMeFlyServer
RUN go build -o server.bin main.go
指定容器入口
CMD /root/gopath/src/BringMeFlyServer/server.bin
Docker指令介绍
查看版本
$ docker version
运行镜像
~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest
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.
(amd64)
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
~]# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
32802c0cfa4d: Pull complete
da1315cffa03: Pull complete
fa83472a3562: Pull complete
f85999a86bef: Pull complete
Digest: sha256:6d0e0c26489e33f5a6f0020edface2727db9489744ecc9b4f50c7fa671f23c49
Status: Downloaded newer image for ubuntu:latest
root@e2442527555f:/# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
root@e2442527555f:/# exit
exit
[root@centos-docker-ex ~]#
显示本地镜像酷内容
~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 93fd78260bd1 2 weeks ago 86.2 MB
hello-world latest 4ab4c602aa5e 3 months ago 1.84 kB
获得帮助
~]# docker --help
显示运行中容器
~]# docker ps
CONTAINER ID IMAGE COMMAND …
显示所有容器
~]# docker ps -a
CONTAINER ID IMAGE COMMAND STATUS NAMES
e2442527555f ubuntu "bash" Exited (0) frosty_goodall
627aa20c5232 hello-world "/hello" Exited (0) heuristic_franklin
停止一个容器
$ docker stop bfd094233f96
删除一个容器
$ docker rm bfd094233f96
进入一个容器
$ docker attach d20f3dc6cd92
重启Docker服务
sudo service docker restart
docker pull 本机ip:5000/hello-world:1.10