From version 1.16, the official Docker Image of Consul is no longer updated at https://hub.docker.com/_/consul. You need to use its official Docker Image at https://hub.docker.com/r/hashicorp/consul to install the latest versions of Consul!
To install Consul using Docker Compose, you can define the content of the Docker Compose file as follows:
1 2 3 4 5 6 |
services: consul: image: hashicorp/consul:latest ports: - 8500:8500 command: "agent -dev -client=0.0.0.0" |
Here, I use the command “agent -dev” to start Consul in development mode. There is an additional parameter “-client=0.0.0.0” used to expose the API with the Consul UI that can be accessed using any IP address!
Now, if you run the command “docker compose up” in the directory containing the Docker Compose file with the above content, you will see the following result:
Now, if you go to http://localhost:8500/, you will see the following result:
So, we have successfully installed Consul using Docker Compose!