Search code examples
wordpressdockerdocker-composedocker-swarm

Can't access running service using Docker Stack and Official Wordpress Docker image


I am trying to deploy a stack with a compose file using the official Wordpress Docker image.

I have stripped down my down my compose file (stack.yml) to this:

version: '3.1'

services:

  wordpress:
    image: wordpress
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_PASSWORD_FILE: /run/secrets/db_password
    secrets:
      - db_password

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_password
    secrets:
      - db_password

secrets:
  db_password:
    file: db_password.txt

With the exception of secrets, this almost exactly what is given in the documentation.

I then run $ docker stack deploy -c stack.yml wordpress.

Running $ docker stack services wordpress confirms that both services are replicated and running.

NAME                  MODE                REPLICAS
wordpress_wordpress   replicated          1/1
wordpress_mysql       replicated          1/1

However, when I try to access from http://localhost:8080 in Chrome, I get the following message:

localhost didn’t send any data.
ERR_EMPTY_RESPONSE

The image documentation also mentions accessing from http://swarm-ip:8080.

I tried running docker node inspect self --format '{{ .Status.Addr }}' which returned the ip 192.168.65.2, however visiting 192.168.65.2:8080 in Chrome returns ERR_CONNECTION_TIMED_OUT.

I'm running Docker 17.06.0-ce-mac19 on Mac Sierra 10.12.6.

Is this just a configuration error on my particular machine? Or am I missing something really obvious?


Solution

  • Please check the contents of db_password.txt. I have checked the above on my system with environment variables instead of secrets, using docker stack and it all works for me