Access WordPress Docker Container From Local Network

A little bit of background info. I have an Ubuntu VM joined to a Windows domain and I would like to access a local WordPress site running in a Docker container from any computer on the network, unfortunately I’m having some trouble.

Please see my WordPress/PHPMyAdmin/MySQL docker file below:

version: '3'

services:
  # Database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: password
    networks:
      - proxy
  #phpmyadmin
  phpymyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
     - '8080:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: password
    networks:
      - proxy
  #Wordpress    
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8000:80'
    restart: always
    volumes: ['./:/var/www/html']
    environment:
      VIRTUAL_HOST: intranet-vm.myADDomainName.com
      VIRTUAL_PORT: 80
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: password
    networks:
      - proxy
      - default
networks:
  proxy:
    external: true
volumes:
  db_data:

And then there’s the proxy container file:

version: '3.2'

network:
  proxy:
    external: true

services:
  proxy:
    image: jwilder/nginx-proxy
    restart: always
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx/conf.d/proxy.conf:/etc/nginx/conf.d/proxy.conf:ro
      - /Users/marcin/Docker/local_share/certificates:/etc/nginx/certs:ro      
    ports:
      - "80:80"
      - "443:443"
    container_name: proxy
    networks:
      - proxy

No matter what I try, I cannot access the WordPress site at intranet-vm.myADDomainName.com. I just want to be able to access the WordPress site from the any computer on the local network without having to use the port number, that way I don’t have to update the hosts file of every PC on the domain.

So far, I added an entry to the Ubuntu hosts file:

127.0.0.1  intranet-vm.myADDomainName.com

I’ve even changed the URL and Site Name in WordPress itself to intranet-vm.myADDomainName.com and I still can’t access it.

Odd too because I can access PHPMyAdmin at intranet-vm.myADDomainName.com:8080, but I can’t access WordPress.

Any assistance would be greatly appreciated.

Source: Docker Questions

LEAVE A COMMENT