This is the 25th day of my participation in the August Challenge


Related articles

Docker series summary: Docker series


Docker installation middleware

  • There is no harm without comparison, so let’s take a look at some of the operations we usually need to install different middleware

  • The RabbitMQ Centos7 installation

  • How to install Redis with Widows and Linux

  • Can look at the installation of these articles, more cumbersome.

  • So what if we used Docker to install and manage this middleware?

  • The following operations use Redis as an example

  • Mirror repository: Redis mirror library

  • ① View the current Docker image

    • docker images
      Copy the code
  • ② Search mirror

    • docker search redis
      Copy the code
  • ③ Pull the latest Redis image

    • docker pull redis:latest
      Copy the code
    • Look again at the Docker imagedocker images
    • Successful pull! The CREATED in this is the creation time, indicating that the latest Redis image was released six days ago!
  • ④ Run the Redis container

    • Docker run -d --name redis-dy -p 6380:6379 redisCopy the code
    • A unique identifier is generated when the run is complete
  • ⑤ Check the running status of the current container

    • docker ps
      Copy the code
    • Everything is all right
  • ⑥ Connect under our Docker startup Redis to try

    • docker exec -it redis-dy /bin/bash
      Copy the code
  • Only the installation steps of Redis middleware are listed here, the rest is not demonstrated.
  • Pretty much everything is the same.
  • So the Installation of Docker helps us simplify a lot of things, so we don’t have to remember so many installation methods.
  • Just pay attention to how Docker is installed.

2. Use Dockerfile to build microservice image

  • What if we write our own project jar packages that also want to run the management as Docker containers?

  • precondition

    • Prepare a JAR with a random controller in it and access it as follows
  • Create a dockerJar folder

    • mkdir dockerJar
      Copy the code
  • Create DockerFile

    • touch DockerFile
      Copy the code
  • 3. Upload the JAR file to the directory

    • # I here is installed rZ to upload files, very convenient use! rzCopy the code
    • View current file: Upload successful!
  • Write DockerFile file

    • Jar # declare the port that needs to be exposed EXPOSE 10005 # Configure the container after startup to execute the command ENTRYPOINT Java ‐ jar/dypractive. JarCopy the code
  • Build the mirror

    • Tag docker build -f Dockerfile -t dypractive:1.0.0Copy the code
    • This step depends on the size of your JAR package to build, and maybe your JDK8 does not have, Docker will give you automatic pull installation, may take a certain amount of time, a little wait oh ~
    • Look at mirrordocker images
    • Jar image built successfully!
  • 6. Enable the custom microservice image

    • Docker run -d --name dyprActive -p 8888:10005 dyprActive. Jar :1.0.0Copy the code
  • ⑦, access test

  • Perfect solution!


The road ahead is long, I see no end, I will search high and low

If you think I bloggers write well! Writing is not easy, please like, follow, comment and give encouragement to the blogger ~ Hahah