- 浏览: 2551385 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker(1)Installation and Images Containers
1. Installation
MAC
I just download the file and install from here https://docs.docker.com/installation/mac/.
> docker --version
Docker version 1.6.2, build 7c8fca2
UBUNTU
> sudo apt-get install -y docker.io
> docker --version
Docker version 1.5.0, build a8a31ef
Start the docker service
> sudo service docker start
Once your docker service is running.
> carl@ubuntu-pilot:~$ ps -ef | grep docker
root 1685 1 0 16:47 ? 00:00:00 /usr/bin/docker -d -H fd://
2. Introduction
docker virtualization is based on the operation system layer, the others are based on hardware layer.
virtual machines —> App A, B - Bins/Libs - Guest OS
Docker —> App B - Bins/Libs
Based on that, one single machine can run thousands of Docker container.
Basic Term
Image: image can use to create docker container, it is template. It is readonly.
Container: Docker run the applications in Containers. Container is on top of Image.
Repository:Repository contains a lot of images.
one repository —> a lot of images —> container on top of image —> application run on top of container
3. Use that on Ubuntu - Images
search the Image
> sudo docker search memcached
Pull the Image
> sudo docker pull memcached
List all the Images
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
node 0.12 f9ba67676f8f 5 days ago 711.8 MB
node 0.12.4 f9ba67676f8f 5 days ago 711.8 MB
node latest f9ba67676f8f 5 days ago 711.8 MB
The list information includes which repository, image tag, image id and when it is created, what is the size of that images.
If we specify the tag, it will go with that tag, if not, it will go with latest.
Use Dockerfile to create a image
http://dockerpool.com/static/books/docker_practice/dockerfile/README.html
> mkdir ubuntu-ruby
> cat Dockerfile
#This is comment
FROM ubuntu:14.04
MAINTAINER Carl Luo <luohuazju@gmail.com>
RUN apt-get -qq update
RUN apt-get -qqy install ruby ruby-dev
Build the image
> sudo docker build -t="ubuntu-ruby:v1" .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
---> 6d4946999d4f
Step 1 : MAINTAINER Docker GreenHand <luohuazju@gmail.com>
---> Using cache
---> 873801ee719d
Step 2 : RUN apt-get -qq update
---> Using cache
---> 4c6db71f543f
Step 3 : RUN apt-get -qqy install ruby ruby-dev
---> Using cache
---> d6f6754ff5dc
Successfully built d6f6754ff5dc
Start the image
> sudo docker run -t -i ubuntu-ruby:v1 /bin/bash
Change the tag
> sudo docker tag d6f6754ff5dc ubuntu-ruby:v2
Save and Load the Image
Save the docker image to your local file system
> sudo docker save -o /home/carl/install/ubuntu-ruby.v1.tar ubuntu-ruby:v1
Load the image from local file
> sudo docker load --input /home/carl/install/ubuntu-ruby.v1.tar
Remove the local images
> sudo docker rmi mongo:3.0
But sometimes, it will complain about remaining containers
> sudo docker rmi centos:centos7
Error response from daemon: Conflict, cannot delete 7322fbe74aa5 because the container 7adc92814fdb is using it, use -f to force
FATA[0000] Error: failed to remove one or more images
Solution:
> sudo docker rmi -f centos:centos7
4. Containers
There are 2 types of starting a container, one is to start a container based on a new image; the other is to resume a stopped container.
Pull one latest ubuntu OS
> sudo docker pull ubuntu
Start the container and run hello sillycat
> sudo docker run ubuntu:14.04 /bin/echo 'hello sillycat'
Start the bash command
> sudo docker run -t -i ubuntu:14.04 /bin/bash
Check the current running container
> sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cef2c743fc0 ubuntu:14.04 "/bin/bash" 4 minutes ago Up 2 minutes drunk_rosalind
Check the docker log
> sudo docker logs drunk_rosalind
Command to check all the container
> sudo docker ps -a
Start the container
> sudo docker stop drunk_rosalind
-d parameter will put the container running in the back, but sometimes we need to login in the container.
Star the ubuntu container with this command
> sudo docker run -idt ubuntu
> sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e0b6b07723c8 ubuntu:14.04 "/bin/bash" 5 seconds ago Up 5 seconds angry_goldstine
> sudo docker attach angry_goldstine
export the snapshot of container to local file
> sudo docker export 7fc47beabcb9 > /home/carl/install/ubuntu.tar
import the snapshot to image
> cat ubuntu.tar | sudo docker import - test/ubuntu:v1.0
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
test/ubuntu v1.0 213dbae711c1 27 seconds ago 188.1 MB
It can be imported from one REMOTE URL
sudo docker import http://xx.xx.xx/ubuntu.tar test/ubuntu:v1
Remote the Container
> sudo docker rm insane_yonath
References:
https://github.com/docker/docker
https://docs.docker.com/installation/mac/
http://aws.amazon.com/elasticmapreduce/
docker references
https://kitematic.com/
https://docs.docker.com/installation/mac/
https://docs.docker.com/installation/
http://segmentfault.com/a/1190000000366923
http://www.jianshu.com/p/26f15063de7d
http://www.infoq.com/cn/articles/docker-containers
http://www.infoq.com/cn/news/2014/12/shopify-docker-experience
http://cn.soulmachine.me/blog/20131026/
https://www.gitbook.com/book/yeasy/docker_practice/details
http://tech.uc.cn/?p=2726
http://dockone.io/article/126
http://dockerpool.com/static/books/docker_practice/install/centos.html
docker on raspberry
https://resin.io/blog/docker-on-raspberry-pi-in-4-simple-steps/
http://blog.xebia.com/2014/08/25/docker-on-a-raspberry-pi/
1. Installation
MAC
I just download the file and install from here https://docs.docker.com/installation/mac/.
> docker --version
Docker version 1.6.2, build 7c8fca2
UBUNTU
> sudo apt-get install -y docker.io
> docker --version
Docker version 1.5.0, build a8a31ef
Start the docker service
> sudo service docker start
Once your docker service is running.
> carl@ubuntu-pilot:~$ ps -ef | grep docker
root 1685 1 0 16:47 ? 00:00:00 /usr/bin/docker -d -H fd://
2. Introduction
docker virtualization is based on the operation system layer, the others are based on hardware layer.
virtual machines —> App A, B - Bins/Libs - Guest OS
Docker —> App B - Bins/Libs
Based on that, one single machine can run thousands of Docker container.
Basic Term
Image: image can use to create docker container, it is template. It is readonly.
Container: Docker run the applications in Containers. Container is on top of Image.
Repository:Repository contains a lot of images.
one repository —> a lot of images —> container on top of image —> application run on top of container
3. Use that on Ubuntu - Images
search the Image
> sudo docker search memcached
Pull the Image
> sudo docker pull memcached
List all the Images
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
node 0.12 f9ba67676f8f 5 days ago 711.8 MB
node 0.12.4 f9ba67676f8f 5 days ago 711.8 MB
node latest f9ba67676f8f 5 days ago 711.8 MB
The list information includes which repository, image tag, image id and when it is created, what is the size of that images.
If we specify the tag, it will go with that tag, if not, it will go with latest.
Use Dockerfile to create a image
http://dockerpool.com/static/books/docker_practice/dockerfile/README.html
> mkdir ubuntu-ruby
> cat Dockerfile
#This is comment
FROM ubuntu:14.04
MAINTAINER Carl Luo <luohuazju@gmail.com>
RUN apt-get -qq update
RUN apt-get -qqy install ruby ruby-dev
Build the image
> sudo docker build -t="ubuntu-ruby:v1" .
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM ubuntu:14.04
---> 6d4946999d4f
Step 1 : MAINTAINER Docker GreenHand <luohuazju@gmail.com>
---> Using cache
---> 873801ee719d
Step 2 : RUN apt-get -qq update
---> Using cache
---> 4c6db71f543f
Step 3 : RUN apt-get -qqy install ruby ruby-dev
---> Using cache
---> d6f6754ff5dc
Successfully built d6f6754ff5dc
Start the image
> sudo docker run -t -i ubuntu-ruby:v1 /bin/bash
Change the tag
> sudo docker tag d6f6754ff5dc ubuntu-ruby:v2
Save and Load the Image
Save the docker image to your local file system
> sudo docker save -o /home/carl/install/ubuntu-ruby.v1.tar ubuntu-ruby:v1
Load the image from local file
> sudo docker load --input /home/carl/install/ubuntu-ruby.v1.tar
Remove the local images
> sudo docker rmi mongo:3.0
But sometimes, it will complain about remaining containers
> sudo docker rmi centos:centos7
Error response from daemon: Conflict, cannot delete 7322fbe74aa5 because the container 7adc92814fdb is using it, use -f to force
FATA[0000] Error: failed to remove one or more images
Solution:
> sudo docker rmi -f centos:centos7
4. Containers
There are 2 types of starting a container, one is to start a container based on a new image; the other is to resume a stopped container.
Pull one latest ubuntu OS
> sudo docker pull ubuntu
Start the container and run hello sillycat
> sudo docker run ubuntu:14.04 /bin/echo 'hello sillycat'
Start the bash command
> sudo docker run -t -i ubuntu:14.04 /bin/bash
Check the current running container
> sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cef2c743fc0 ubuntu:14.04 "/bin/bash" 4 minutes ago Up 2 minutes drunk_rosalind
Check the docker log
> sudo docker logs drunk_rosalind
Command to check all the container
> sudo docker ps -a
Start the container
> sudo docker stop drunk_rosalind
-d parameter will put the container running in the back, but sometimes we need to login in the container.
Star the ubuntu container with this command
> sudo docker run -idt ubuntu
> sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e0b6b07723c8 ubuntu:14.04 "/bin/bash" 5 seconds ago Up 5 seconds angry_goldstine
> sudo docker attach angry_goldstine
export the snapshot of container to local file
> sudo docker export 7fc47beabcb9 > /home/carl/install/ubuntu.tar
import the snapshot to image
> cat ubuntu.tar | sudo docker import - test/ubuntu:v1.0
> sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
test/ubuntu v1.0 213dbae711c1 27 seconds ago 188.1 MB
It can be imported from one REMOTE URL
sudo docker import http://xx.xx.xx/ubuntu.tar test/ubuntu:v1
Remote the Container
> sudo docker rm insane_yonath
References:
https://github.com/docker/docker
https://docs.docker.com/installation/mac/
http://aws.amazon.com/elasticmapreduce/
docker references
https://kitematic.com/
https://docs.docker.com/installation/mac/
https://docs.docker.com/installation/
http://segmentfault.com/a/1190000000366923
http://www.jianshu.com/p/26f15063de7d
http://www.infoq.com/cn/articles/docker-containers
http://www.infoq.com/cn/news/2014/12/shopify-docker-experience
http://cn.soulmachine.me/blog/20131026/
https://www.gitbook.com/book/yeasy/docker_practice/details
http://tech.uc.cn/?p=2726
http://dockone.io/article/126
http://dockerpool.com/static/books/docker_practice/install/centos.html
docker on raspberry
https://resin.io/blog/docker-on-raspberry-pi-in-4-simple-steps/
http://blog.xebia.com/2014/08/25/docker-on-a-raspberry-pi/
发表评论
-
Update Site will come soon
2021-06-02 04:10 1677I am still keep notes my tech n ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 294Hadoop Docker 2019 Version 3.2. ... -
Nginx and Proxy 2019(1)Nginx Enable Lua and Parse JSON
2019-12-03 04:17 448Nginx and Proxy 2019(1)Nginx En ... -
Data Solution 2019(13)Docker Zeppelin Notebook and Memory Configuration
2019-11-09 07:15 294Data Solution 2019(13)Docker Ze ... -
Data Solution 2019(10)Spark Cluster Solution with Zeppelin
2019-10-29 08:37 248Data Solution 2019(10)Spark Clu ... -
AMAZON Kinesis Firehose 2019(1)Firehose Buffer to S3
2019-10-01 10:15 322AMAZON Kinesis Firehose 2019(1) ... -
Rancher and k8s 2019(3)Clean Installation on CentOS7
2019-09-19 23:25 313Rancher and k8s 2019(3)Clean In ... -
Pacemaker 2019(1)Introduction and Installation on CentOS7
2019-09-11 05:48 343Pacemaker 2019(1)Introduction a ... -
Crontab-UI installation and Introduction
2019-08-30 05:54 454Crontab-UI installation and Int ... -
Spiderkeeper 2019(1)Installation and Introduction
2019-08-29 06:49 509Spiderkeeper 2019(1)Installatio ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 370Supervisor 2019(2)Ubuntu and Mu ... -
Supervisor 2019(1)CentOS 7
2019-08-19 09:33 331Supervisor 2019(1)CentOS 7 Ins ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 373Redis Cluster 2019(3)Redis Clus ... -
Amazon Lambda and Version Limit
2019-08-02 01:42 438Amazon Lambda and Version Limit ... -
MySQL HA Solution 2019(1)Master Slave on MySQL 5.7
2019-07-27 22:26 529MySQL HA Solution 2019(1)Master ... -
RabbitMQ Cluster 2019(2)Cluster HA and Proxy
2019-07-11 12:41 463RabbitMQ Cluster 2019(2)Cluster ... -
Running Zeppelin with Nginx Authentication
2019-05-25 21:35 323Running Zeppelin with Nginx Aut ... -
Running Zeppelin with Nginx Authentication
2019-05-25 21:34 323Running Zeppelin with Nginx Aut ... -
ElasticSearch(3)Version Upgrade and Cluster
2019-05-20 05:00 329ElasticSearch(3)Version Upgrade ... -
Jetty Server and Cookie Domain Name
2019-04-28 23:59 404Jetty Server and Cookie Domain ...
相关推荐
You will be introduced to the process of downloading Docker images and running them as containers. You'll learn how to run containers as a service (CaaS) and also discover how to share data among ...
Learning Docker - Second Edition by Jeeva S....This step-by-step guide will walk you through the features and use of Docker, from Docker software installation to the impenetrable security of containers.
What You Will LearnDevelop containerized applications using the Docker version 17.03Build Docker images from containers and launch themDevelop Docker images and containers leveraging DockerfilesUse ...
Using carefully designed examples, the book teaches you how to orchestrate containers and applications from installation to removal. Along the way, you'll discover techniques for using Docker on ...
Chapter V - Working With Docker Images Chapter VI - Working With Docker Containers Chapter VII - Working With Docker Machine Chapter VIII - Docker Networking Chapter IX - Composing Services Using ...
Using carefully designed examples, the book teaches you how to orchestrate containers and applications from installation to removal. Along the way, you'll discover techniques for using Docker on ...
conversations toward Docker and containers. I explained how package management was nice, but enforcing file system isolation as a default solved several management problems. I rattled on about ...
2.1.2 Deployment of Docker Containers. 6 2.1.3 Deployment recommendations. 7 2.1.4 Test data and computational benchmarks. 8 2.2 Web Image Processing. 10 2.2.1 WIP processing functionality. 10 ...