系统:centos7
内核版本:inux localhost.localdomain 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
参考:
1. docker 安装
-
curl -fsSL https://get.docker.com/ | sh
-
sudo service docker start
-
ps -ef |grep docker
root 11882 1 1 02:35 ? 00:00:38 /usr/bin/docker daemon -H fd://
lujj 16828 10761 0 03:28 pts/0 00:00:00 grep --color=auto docker
-
sudo docker run hello-world
2. 镜像和容器
Docker Engine provides the core Docker technology that enables images
and containers. As the last step in your installation, you ran the
Engine docker run hello-world command. With this one command, you completed the core tasks to using Engine. The command you ran had three parts.
A container is a stripped-to-basics version of a Linux operating system. An image is software you load into a container. When you ran the command, the Engine software:
-
checked to see if you had the hello-world software image
-
downloaded the image from the Docker Hub (more about the hub later)
-
loaded the image into the container and “ran” it
A Docker image, though, is capable of much more. An image can start
software as complex as a database, wait for you (or someone else) to add
data, store the data for later use, and then wait for the next person.
Who built the hello-world software image though? In this
case, Docker did but anyone can. Docker Engine lets people (or
companies) create and share software through Docker images. Using Docker
Engine, you don’t have to worry about whether your computer can run the
software in a Docker image — a Docker container can always run it.
3. 查找运行whalesay 镜像
docker run docker/whalesay cowsay boo-boo
4. 创建自己的镜像
-
mkdir ~/dockerbuild
-
cd ~/dockerbuild
-
touch Dockerfile
-
cat >Dockerfile1 <
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay
EOF
-
docker build -t docker-whale .
-
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
hello-world latest 690ed74de00f 5 months ago 960 B
docker/whalesay latest 6b362a9f73eb 9 months ago 247 MB
-
docker run docker-whale
docker-whale 新建镜像的名称
5. Create a Docker Hub Account & repository
6. 标记、推送、拉取镜像
-
docker images
-
REPOSITORY TAG IMAGE ID CREATED SIZE
-
docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
-
hello-world latest 690ed74de00f 5 months ago 960 B
-
docker/whalesay latest 6b362a9f73eb 9 months ago 247 MB
8dcf3d51d4dc 镜像ID
1)使用镜像ID 和docker tag 命令 标记镜像
docker tag 8dcf3d51d4dc docker27014/docker-whale:latest
docker tag imageID hubAccountID/imageName:tags
-
docker images
-
REPOSITORY TAG IMAGE ID CREATED SIZE
-
docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
-
docker27014/docker-whale latest 8dcf3d51d4dc 2 hours ago 255.7 MB
-
hello-world latest 690ed74de00f 5 months ago 960 B
-
docker/whalesay latest 6b362a9f73eb 9 months ago 247 MB
2)命令行登录docker hub
-
docker login --username=yourhubusername --email=youremail@company.com
3) 推送镜像
-
docker push docker27014/docker-whale
推送成功后,删除本地镜像
-
docker rmi -f 8dcf3d51d4dc
-
docker rmi -f docker-whale
3) 从本人资源库拉取镜像
-
docker run docker27014/docker-whale
阅读(1108) | 评论(0) | 转发(0) |