Mirror already exists. Let's learn how to use it.
================================================
Mirror is the most important of the three cores and the most popular keyword since the birth of Docker!
Docker needs a local mirror before running the container with the following priority:
1) Locally existing mirrors
2) Default mirror warehouse (default uses the warehouse in the Docker Hub public registration server)
3) User-defined Configuration - Use a custom mirror warehouse
This chapter describes the specific operations around the core concept of mirroring, including how to download mirrors from the Docker Hub repository to the local location using the pull command, how to view and manage the local existing mirroring information, how to search and filter using the search command in the remote repository, how to delete mirroring tags and mirroring files, how to create user-customized mirrors and save themSave as an external file.Finally, it shows you how to push your own mirror into the Docker Hub repository.
3.1 Getting Mirrors
Mirrors are a prerequisite for running containers. Officials have provided hundreds of thousands of mirrors for everyone to download openly!
docker images REPOSITORY TAG IMAGE ID CREATED SIZE myspringboot/0.1 latest c457facb0530 36 minutes ago 518MB myspringboot/latest latest 06146e591750 About an hour ago 518MB <none> <none> 21016d598a9d 3 days ago 120MB ubuntu latest 14f60031763d 11 days ago 120MB root@myhost:~/docker_image_test/myspringboot# docker rmi 21016d598a9d Error response from daemon: conflict: unable to delete 21016d598a9d (must be forced) - image is being used by stopped container e1271e25af7f root@myhost:~/docker_image_test/myspringboot# docker pull ubuntu:14.04 14.04: Pulling from library/ubuntu 7ee37f181318: Pull complete df5ffabe5e97: Pull complete ae2040ed51a1: Pull complete 3ce7010d244b: Pull complete 2538b201d2a6: Pull complete Digest: sha256:13eecbc0e57928c1cb3ccca3581e2a6f4b0f39c1acf5a279e740e478accd119b Status: Downloaded newer image for ubuntu:14.04 root@myhost:~/docker_image_test/myspringboot# docker images REPOSITORY TAG IMAGE ID CREATED SIZE myspringboot/0.1 latest c457facb0530 37 minutes ago 518MB myspringboot/latest latest 06146e591750 About an hour ago 518MB <none> <none> 21016d598a9d 3 days ago 120MB ubuntu latest 14f60031763d 11 days ago 120MB ubuntu 14.04 54333f1de4ed 11 days ago 188MB
If the tag is not specified explicitly, the latest tag is selected by default to download the latest version of the image
===Container
Containers are another core concept.
Simply put, a running instance of a container is mirrored, unlike static, read-only files, where the container has a writable file layer for runtime needs.
4.1 Create Containers
Operating containers is as simple and fast as directly operating applications.Docker containers are so lightweight that users can create or delete them at any time!
1 New Container
docker images REPOSITORY TAG IMAGE ID CREATED SIZE myspringboot/0.1 latest c457facb0530 2 hours ago 518MB myspringboot/latest latest 06146e591750 2 hours ago 518MB <none> <none> 21016d598a9d 3 days ago 120MB ubuntu latest 14f60031763d 11 days ago 120MB ubuntu 14.04 54333f1de4ed 11 days ago 188MB root@myhost:~/docker_image_test/myspringboot# docker create -it myspringboot/0.1 6e23d132b2ae736729e9ca6f5b01651eeb9f34433348460e3b5749c4e1e11f54 root@myhost:~/docker_image_test/myspringboot# docker ps-a docker: 'ps-a' is not a docker command. See 'docker --help' root@myhost:~/docker_image_test/myspringboot# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6e23d132b2ae myspringboot/0.1 "./run.sh" 9 seconds ago Created
At this point, the container is stopped and can be started using the docker start command
docker start fervent_montalcini fervent_montalcini
Well, what about the startup container?
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
===After a lot of hassles, offer the full executable version
cat run.sh #!/bin/bash java -cp ./ -jar app.jar
cat ddddir/Dockerfile FROM ubuntu MAINTAINER liuzhq 837500869@qq.com #RUN apt-get update && apt-get install maven #RUN mvn -X clean compile package -DskipTests=true VOLUME /tmp #RUN ls -al RUN echo "begin to create docker image" && apt-get -y update && apt-get -y install openjdk-8-jdk #COPY ./target/myspringboot-0.2-SNAPSHOT.jar ./app.jar COPY */*.jar ./app.jar COPY */*/application*.properties ./ COPY *.sh ./ RUN chmod +x *.sh RUN touch ./log.log RUN chmod +x *.log EXPOSE 9990 CMD ["./run.sh"]
create mirror
docker build -t myspringboot/0.6 -f ./ddddir/Dockerfile ./
One-click Start
iptables -I INPUT -p tcp --dport 9990 -j ACCEPT
docker run -it -p 9990:9990 myspringboot/0.6:latest
Perfect!