Docker Community Forums

Share and learn in the Docker community.

Automate deployment for Docker containers

I am using Docker container for managing my Application. I have deployed the Application at Multiple Servers.

Now I want to update that Application on all my servers. Thus I am looking for a solution to automate the deployment process.

What I have done so far to achieve this =>

I have configured a docker registry on a Server ( Main Server from which all the clients will pull the images ). I have tested pull and push from the client side and it is working properly.

But the problem here is that I have to manually pull the application on all the client side from the docker registry.

I found some open source implementation for this purpose ( WatchTower and ouroboros ) But according to my understanding, this solution needs registry as DockerHub or private registry hosted by Docker. ( Please correct me if I am wrong )

Question:

In my scenario, I am hosting the Docker Registry at my private server. So I am looking for the solution that can detect the changes in the Registry an automatically update the Container ( i.e. Application )

How did you come to the conclustion that a private registry would be required to be hosted by Docker?

The documentation on https://containrrr.github.io/watchtower/usage-overview/ (when trying to access https://github.com/v2tec/watchtower a forward to https://github.com/containrrr/watchtower takes place - so I assume containrrr is legit) says:

If pulling images from private Docker registries, supply registry authentication credentials with the environment variables REPO_USER and REPO_PASS or by mounting the host’s docker config file into the container (at the root of the container filesystem / ).

They refer to a registry for Docker images. This is a category and not a brand or specific product. Your image repo could be anything: Gitlab, Nexus3, Artifactory, Quay.io, Portus, DTR, Registry2,… and it should work as far as you follow the documentation on how to pass the credentials into watchtower.

If your deployments are Swarm deployments, you would want to use https://hub.docker.com/r/mazzolino/shepherd instead of watchtower.

update: according the documentation of ouroboros, it supports plain containers and swarm services as well.

Actually, I am not sure if I came up with the right conclusion that’s why I said this.

Anyways thanks for the response and clarification. To test this theory I did following steps =>

  1. I have configured the docker at my server. After that, I have configured my container ( i.e. My Application ) on the device and I am using docker-compose for building my application.

  2. Now I logged into my Private Docker Register ( It is hosted at another server ) using the following command docker login <URL_of_my_private_registry> from the server on which I have my application which needs to be updated. I made sure that before login there was nothing related to docker at this path ~/. Once I logged in I got a config.json inside this directory. Inside the config.json file, I have auths and httpheaders JSON.

  3. Now for configuring the WatchTower, I have used the following command =>

docker run -d \
  --name watchtower \
  -e REPO_USER=username \
  -e REPO_PASS=password \
  -e WATCHTOWER_POLL_INTERVAL=15 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower container_to_watch --debug
  1. -e REPO_USER=username \ In this command I have replaced username and password with the username and passwword that I have configured for the Registry.

  2. Now when I checked the logs of my WatchTower using docker logs -f <container-id> I got the following output.

time="2019-07-02T07:14:54Z" level=debug msg="Sleeping for a seconds to ensure the docker api client has been properly initialized."
time="2019-07-02T07:14:55Z" level=debug msg="Retrieving running containers"
time="2019-07-02T07:14:55Z" level=debug msg="There are no additional watchtower containers"
time="2019-07-02T07:14:55Z" level=debug msg="Starting Watchtower and scheduling first run: 2019-07-02 07:15:10 +0000 UTC m=+15.597435652"

time="2019-07-02T07:15:10Z" level=debug msg="Checking containers for updated images"
time="2019-07-02T07:15:10Z" level=debug msg="Retrieving running containers"
time="2019-07-02T07:15:10Z" level=debug msg="Scheduled next run: 2019-07-02 07:15:25 +0000 UTC"

But when I check my docker registry logs I am unable to see any log related to this polling.

That’s Why I came up with this conclusion. Anyways can you please tell me what I have done wrong here in the configuration.

I guess there is a difference between mounting the config.json and passing the username and password. The config.json does include the domain name of the registry as well.

If you performend docker login <URL_of_my_private_registry> as root and started a compse stack that looks similar like this:

version: "2.4"
services:
  test:
    image: <URL_of_my_private_registry>/<org>/<image>:<tag>
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/.docker/config.json:/config.json
    command: --interval 15

I would assume that things should work. Watchtower pulls the image and compares the image id with the running container with the latest pulled image’s image id. The repository domain name is included in the image attribut. The config.json includes a valid token or the credentials for the same domain name. This should work.

How install python with mysqlserver or mariaDb on raspberry pi 3 b stretch armhf in docker using Dockerfile or docker-compose