Docker practice: From getting started to practice
I. What is Docker?
Docker is a docker. When it becomes a technology, it also serves as a docker. The official website describes it as follows: "Docker is a development platform used to build, publish, and run distributed applications for developers and system administrators ." That is to say, if you compare your application to a cargo, the Docker will quickly load them onto the ship using containers. Fast, simple, and efficient.
It is written in the Go language and is the "Container" for running programs (Linux containers), implementing application-level isolation (sandbox ). Multiple containers are mutually affected during runtime, ensuring security and stability.
I like it because it is fast deployment, safe operation, and does not pollute my system.
Ii. Try it now!
The official website provides an interactive tutorial to help you easily understand the basic usage of Docker. Please try it now!
Iii. Installation
The official website directly supports installing Docker on 64-bit Linux. However, if you want to run Docker on a 32-bit Linux system, some attempts have been made. For example, in 32Ubuntu, click to open the link.
For installation of other systems, refer to the official website. The following describes how to install them in Ubuntu14.04.
1. Add the image to the program source:
~$ sudo sh -c "echo deb http://mirror.yandex.ru/mirrors/docker/ docker main > /etc/apt/sources.list.d/docker.list"
2. Then update
$ sudo apt-get update
3. fix it if an error is reported:
W: GPG error: http://mirror.yandex.ru docker Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D8576A8BA88D21E9
Solve this error:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D8576A8BA88D21E9Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.RmJ1SUpsXX --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D8576A8BA88D21E9gpg: requesting key A88D21E9 from hkp server keyserver.ubuntu.comgpg: key A88D21E9: public key "Docker Release Tool (releasedocker) <docker@dotcloud.com>" importedgpg: Total number processed: 1gpg: imported: 1 (RSA: 1)
4. Download docker:
$ sudo apt-get install lxc-docker
Wait for the download to complete.
In addition, this command may help:
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
Iv. Preliminary use
Enter docker in the terminal to print out the docker command list:
Commands: attach Attach to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders from a container's filesystem to the host path create Create a new container diff Inspect changes on a container's filesystem events Get real time events from the server exec Run a command in a running container export Stream the contents of a container as a tar archive history Show the history of an image images List images import Create a new filesystem image from the contents of a tarball info Display system-wide information inspect Return low-level information on a container kill Kill a running container load Load an image from a tar archive login Register or log in to a Docker registry server logout Log out from a Docker registry server logs Fetch the logs of a container port Lookup the public-facing port that is NAT-ed to PRIVATE_PORT pause Pause all processes within a container ps List containers pull Pull an image or a repository from a Docker registry server push Push an image or a repository to a Docker registry server restart Restart a running container rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save an image to a tar archive search Search for an image on the Docker Hub start Start a stopped container stop Stop a running container tag Tag an image into a repository top Lookup the running processes of a container unpause Unpause a paused container version Show the Docker version information wait Block until a container stops, then print its exit code
Next we can try to use these commands, but before proceeding to the next step, we should first understand several concepts.
5. Important Concepts
1. image
An image is a read-only template. For example, an image can contain a complete Ubuntu system and install apache.
Images can be used to create Docker containers.
Other people make images, so we can use them easily. This is what attracts me.
2. Docker container
Docker uses containers to run applications. A container is an instance created from an image (object-oriented feeling, class, and object). It can be started, started, stopped, and deleted.
3. Warehouse
This is a place where images are stored. For example, the largest public repository is Docker Hub.
6. Several Simple practices
1. search
Search for the wordpress blog image in the repository, as shown below:
$ docker search wordpressNAME DESCRIPTION STARS OFFICIAL AUTOMATEDwordpress The WordPress rich content management syst... 185 [OK]
2. Download this image
$ docker pull wordpresswordpress:latest: The image you are pulling has been verified
3. view your own image
$ docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZElinc-wiki latest b5a1e34b01c2 27 hours ago 689.7 MBubuntu latest 5ba9dab47459 5 days ago 188.3 MBwordpress latest ecc04d6d638c 6 days ago 470 MB
4. Simple operation
Run wordpress to configure mysql. run ubuntu to demonstrate run.
$ docker run -it ubuntu /bin/bashroot@46ff2a695ce1:/# echo "I am linc"I am linc
Now, the experience is over. There will be more exciting practices in the future, waiting for us, Docker, We are here!
Refer:
Https://docs.docker.com/installation/ubuntulinux/
Https://bitnami.com/stack/mediawiki
Https://docs.docker.com/userguide/
Https://dockerpool.com/static/books/docker_practice
Http://zhumeng8337797.blog.163.com/blog/static/1007689142014524115743806/
Http://www.cnblogs.com/imoing/p/dockervolumes.html
Https://github.com/docker/fig/issues/88