This blog mainly records examples of commands for mirroring operations and container operations. If you are interested, you can learn it with the editor!
table of Contents
Mirror operation command
Docker image operation example
This is the official website of docker, docker pull installs the image, that is, docker pull is actually pulled from the official website.
docker official website: https://hub.docker.com/
View version number
For example, docker pull mysql, you can see some version numbers of mysql from the official website tag
Default version installation image
If you do not write the version number, the default is the latest version in
the installed official website. This means that the installation is complete.
View the installed image
Specify the mirror version to install
Of course, we can also choose to install the specified version: docker pull Image name: tag
Delete the specified mirror
At this time, there will be two mysql, two different versions.
Delete the image: docker rmi image-id
Container operation command
If you want to know more, you can go directly to the official website to learn:
docker official website: https://docs.docker.com/engine/reference/commandline/docker/
Docker container operation example
We can understand the process of images and containers as follows:
Software image (QQ installer) ---- run image ---- generate a container (running software, running QQ);
If you want to run a container, you must first have a mirror image of this software, here is tomcat as an example:
1. Search mirror:docker search tomcat
Prove that there is no problem with the docker environment!
2. Pull the mirror image:docker pull tomcat
3. Start the container: docker run ‐‐name mytomcat ‐d tomcat:latest
if it is the latest version installed, you can omit the following version number
4. View the running container:docker ps
5. Stop the running container:docker stop 容器的id
6. View all containers:docker ps ‐a
7. Start the container: docker start 容器id
8. Delete a container: docker rm 容器id
9. Start a tomcat with port mapping: docker run ‐d ‐p 8888:8080 tomcat
10. View the container log:docker logs container‐name/container‐id