2

I am starting with docker and I try to set up wordpress instance.

I use docker-compose to establish a wordpress instance which is up and running, but I can't find any wordpress files that should be imported into the project.

I guess this might be a Windows 10 feature and on Linux/MacosX everything runs more smoothly. Maybe the volume path is not set properly. This refers to the wordpress docker container, but I guess it would be the same using something else.

Please provide a suggestion as I am being completely stuck on this.

I created the following docker-compose.yaml file:

version: '3'

services:
  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: wordpress
    networks:
      - wpsite
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8000:80'
    restart: 'always'
    volumes: 
      - ./:/var/www/html
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    networks:
      - wpsite
networks:
  wpsite:
volumes:
  db_data:

I find it strange that If I change:

volumes: 
  - ./:/var/www/html

into

volumes: 
  - ./:/var/www

an empty html folder appears in my project. So thefile path seems to be set properly.

I was investigating docker settings and shared my C disk. Path is c:\projects\project.

I have no idea what to do next. Any help would be welcome. Thanks.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Witek85
  • 21
  • 1
  • thank you! finally it is really working now in users folder. I still don't know which kind of permissions I need to grant to allow docker to mount files outside users folder, like in. /c/projects – Witek85 Dec 19 '19 at 08:45

2 Answers2

1

Try changing:

volumes: 
  - ./:/var/www/html

to:

volumes: 
  - /c/projects/project:/var/www/html

And then your WordPress files should be in c:\projects\project

Extra Info:

Here's my working WordPress config, for Docker Desktop on a Windows 10 machine:

version: '2'

services:
  wordpress:
    image: wordpress:latest
    hostname: mia
    restart: unless-stopped
    ports:
      - 80:80
    environment:
      WORDPRESS_DB_HOST: mysql:3306
      WORDPRESS_DB_USER: "mydb"
      WORDPRESS_DB_PASSWORD: "mydbpw"
      WORDPRESS_DB_NAME: "mydb"
    volumes:
      - /f/Sites/mia:/var/www/html
    networks:
      - occms
      - ocdb

networks:
  occms:
    external:
      name: olympus-cms
  ocdb:
    external:
      name: olympus-db

Notes:

  • I use an external mysql container in the above setup.
  • I also connect the WordPress container to 2 pre-existing docker bridge networks.
  • After the WordPress container is running, all of my WordPress files are available on my Windows machine at f:\Sites\mia
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
  • thanks, files are still not visible. they are only if I launch up command from users folder, so I guess I need to grant some additional permissions. – Witek85 Dec 19 '19 at 09:34
  • @Witek85 Are you using Docker Toolbox or Docker Desktop? – J. Scott Elblein Dec 20 '19 at 01:35
  • J. Scott Elblein Docker desktop – Witek85 Dec 20 '19 at 11:15
  • @Witek85 I've added a working example to the post, maybe try copying and editing it to match your needs? I do have drives `C:` and `F:` shared in the Docker Desktop shared folders area in it's settings. – J. Scott Elblein Dec 20 '19 at 19:03
  • @Witek85 btw, I created a AutoHotkey script to make creating Windows mount paths easier if you're interested. https://stackoverflow.com/questions/23439126/how-to-mount-a-host-directory-in-a-docker-container/54619756#54619756 – J. Scott Elblein Dec 20 '19 at 19:05
0

Maybe it's a permission issue, it's a known problem with Docker on Windows. Try moving both your Docker container and your project to c:\users\YOUR-USER-HERE\project and check again.

Answer provided in comment by cabrerahector

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94