1. Image Management 1.1. List Mirrors
Sudo Docker Images
1.2. View the image
Sudo Docker images xxxx
1.3. Pull the image
Sudo Docker pull Ubuntu
1.4. Find the image
Sudo Docker Search MySQL
1.5. Remove the image
sudo docker RMI xxxxx (Force)
1.6. Build the mirrored 1.6.1. Docker Commit
Deprecated, it is recommended to use Docker build+ Docker file
1.6.2. Docker Build + Dockerfile
Create a Static_web directory
To create a dockerfile configuration file:
Build:
1.6.3. Building images from a git repository
1) git Create Dockerfile
Input file Contents:
# vesion:0.0.1
From ubuntu:14.04
Maintainer Jay Zhan "[Email protected]"
RUN Apt-get install-y Nginx
RUN Echo ' Hi, I am in You container ' >/usr/share/nginx/html/index.html
EXPOSE 8090
2) Get raw links to dockerfile files in GitHub
Https://raw.githubusercontent.com/duruo850/docker/master/test.dockerfile
Shorthand
Https://rawgit.com/duruo850/docker/master/test.dockerfile
3) Use the link build
sudo docker build-t= "Jay/web_from_git" \
Https://rawgit.com/duruo850/docker/master/test.dockerfile
4) View image
5) Cache Mirroring
Every time the build of Docker caches a local mirror, so from which step error, enter the pre-image into the command to know what the problem;
If the build process is the same, the same image will be used
If you do not want to use the cache, such as the Apt-get Update command, the APT package cache will not be refreshed, and the cache should not be used
sudo docker build–no-cache-t= "Jay/web_from_git".
6) boot the container from the mirror
sudo docker run-i-t-p 10080:80--name static_web2 jay/static_web nginx-g "daemon off;"
Map 80 ports of a virtual machine using a host's 10080 port
To view the host's 10080 port effect:
Consistent with the output of our Nginx index.html.
7) Push the image to the Docker hub
Error: Unauthorized:access to the requested resource are not authorized
WORKAROUND: Use Docker login to log in first
Can only be uploaded to the repository of the Docker hub account (Docker hub account/xxxxxx) and cannot be uploaded to the root repository (xxxxx),
Go to the Docker hub account to view the warehouse:
1.6.4. Auto-Build
Source code hosted on GitHub
When GitHub code changes, Dockerhub automatically acquires Dockerfile and automatically builds Docker containers
Github
The GitHub code root directory needs to provide a dockerfile configuration file
DockerHub
1.6.5. dockerfile directive
The CMD directive specifies the command to run when a container starts. This is similar to the Run command, except that the Run command is a command that is built to run. The Run command can overwrite the cmd command
New Dockerfile:
To build the image:
Boot Image:
The Run command overrides:
The LS command overrides the/bin/bash command
The only difference between the entrypoint and CMD commands is that they are not overwritten by the Run command
The command line parameters of run are passed to the entrypoint command again as arguments
Run can overwrite the command with the-ENTRYPOINT flag
Create mirror when building a new container, a working directory is set inside the container, and the entrypoint and/or CMD commands are executed in this directory
Run can overwrite the command with the-W flag
Setting environment variables during the mirroring build process
Environment variables are persisted to any container in the mirrored build
Run can use the-e flag to pass environment variables that will only be valid at run time
Used to specify the running user of the image
Run can overwrite the variable by using the-u flag
If you do not specify a user group, the default user group is root
Used to add volumes to a mirrored-based container, data sharing capabilities
Used to copy files and directories in the build environment into a mirror,
Can add any file of the build environment
Some archive files (GZIP,TAR,XZ,BZIP2) are unpacked and then placed in the target directory
If the directory location does not exist, Docker will create this full path for us,
The add command makes the build cache invalid
Similar to the Add command, but copy does not extract and unpack the archive as it did add
Only files under the build directory can be copied, and Dockerfile in the same directory
If the directory location does not exist, Docker will create this full path for us,
Add a trigger for the mirror, and when one mirror is treated as the underlying image of another mirror, the trigger for that mirror will execute
To prevent recursive calls, these commands cannot be used in Onbuild: From, onbuild, maintainer, etc.
docker--image management of PAAs architecture