docker learn
ubuntu 安装docker
参考https://docs.docker.com/engine/install/ubuntu/
sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
$ sudo docker run hello-world
第一个docker Dockerfile
# Dockerfile
FROM ubuntu
build
$ docker build -t carl/learn:1.0 .
运行
$ docker run -it carl/learn:1.0 bash
退出来以后什么也不会保存。可以在退出前,在另外的窗口提交更改
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
$ docker commit c3f279d17e0a carl/learn:1.1
f5283438590d
$ docker images
REPOSITORY TAG ID CREATED SIZE
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
how to copy file from docker container to local host
https://stackoverflow.com/questions/22049212/copying-files-from-docker-container-to-host
docker cp :/file/path/within/container /host/path/target
$ sudo docker cp goofy_roentgen:/out_read.jpg .
如何保存image
You will need to save the Docker image as a tar file:
docker save -o <path for generated tar file> <image name>
Then copy your image to a new system with regular file transfer tools such as cp, scp or rsync(preferred for big files). After that you will have to load the image into Docker:
docker load -i <path to image tar file>
PS: You may need to sudo all commands.
EDIT: You should add filename (not just directory) with -o, for example:
docker save -o c:/myfile.tar centos:16
如何将Docker容器通过独立IP暴露给局域网
- 参考https://www.cnblogs.com/Jing-Wang/p/10848960.html
- 参考https://blog.csdn.net/lvshaorong/article/details/69950694
参考
How to copy Docker images from one host to another without using a repository?
https://docs.docker.com/engine/reference/commandline/commit/
还没有评论,来说两句吧...