A
A
Alexander Pankov2019-08-29 22:18:57
Docker
Alexander Pankov, 2019-08-29 22:18:57

How to mount folder with files in docker?

Hello, I'm learning docker.
I work on macos.
Installed https://docs.docker.com/toolbox/toolbox_install_mac/ they say it works faster through it.
wrote config:

version: '2'

services:
  php:
    build: ./docker/php/
    container_name: php
    volumes_from:
      - source
    ports:
      - '0.0.0.0:9000:9000'
    links:
      - mysql
      - memcached
    networks:
      - bitrix
    restart: always
  web_server:
    build: ./docker/nginx/
    container_name: webserver
    depends_on:
      - source
    volumes_from:
      - source
    ports:
      - '0.0.0.0:80:80'
      - '0.0.0.0:443:443'
    links:
      - php
    networks:
      - bitrix
    restart: always
  mysql:
    build: ./docker/mysql
    container_name: mysql
    volumes_from:
      - source
    ports:
      - '0.0.0.0:3306:3306'
    #      - 'docker.for.mac.localhost:3306'
    environment:
      MYSQL_DATABASE: ikea
      MYSQL_USER: root
      MYSQL_PASSWORD: root
      MYSQL_ROOT_PASSWORD: root
    command: mysqld --sql-mode=""
    networks:
      - bitrix
    restart: always
  memcached:
    image: memcached:1.5-alpine
    container_name: memcached
    volumes_from:
      - source
    ports:
      - '0.0.0.0:11211:11211'
    networks:
      - bitrix
    restart: always
  source:
    image: alpine:latest
    container_name: source
    volumes:
      - ./docker/logs/nginx:/var/log/nginx
      - ./docker/logs/php:/var/log/php
      - ./docker/logs/mysql:/var/log/mysql
      - ./docker/logs/memcached:/var/log/memcached
      - ./docker/data/mysql:/var/lib/mysql
      - ./docker/data/memcached:/var/lib/memcached
      #- ./www/html:/var/www/html
      - ./code:/var/www/bitrix
      #- /etc/localtime:/etc/localtime/:ro
    networks:
      - bitrix
networks:
  bitrix:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.100.0.0/24

Bitrix site.
after the command
docker-compose up -d --build
everything started:
Creating source ... done
Creating mysql     ... done
Creating memcached ... done
Creating php       ... done
Creating webserver ... done

but when I type my domain in the browser (which I registered in nginx, hosts), I get the answer "Unable to access the site"
I decided to go into the container itself and see what's there, through the command:
docker exec -it webserver bash
I went in, I see my nginx configs, go to the folder where the files should be, but it’s empty there, they didn’t mount, .. there is my /var/www/bitrix folder, but it’s empty, hence the error in the browser, tell me what’s the matter?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Stolyarov, 2019-08-29
@Ni55aN

You need to share the disk where the directory is mounted. This was a problem on Windows, I think for poppy you also need to share folders

V
Vasily Shakhunov, 2019-08-30
@inf

web_server:
    build: ./docker/nginx/
    container_name: webserver
    volumes:
      - ./my/volume:/container/volume

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question