0

docker-compose.yml:

    version: '3'
    services:
      ezmove:
        volumes:
          - /host-dir:/home/container-dir    
        build:
          context: .
          args:
            BRANCH: develop

Dockerfile:

FROM appcontainers/ubuntu:xenial

MAINTAINER user <user>

RUN apt-get update -y --no-install-recommends \
    && apt-get install -y --no-install-recommends python3.5-minimal python3.5-venv \    
    && apt-get install -y --no-install-recommends git \
    && apt-get install -y --no-install-recommends python-pip \
    && pip install --upgrade pip \  
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /home/container-dir 

WORKDIR /home/container-dir 

RUN /bin/bash - c "sh ./script.sh"

At the time of build the docker container How to map local directory to container

When $ docker-compose up, it will starts to build container but after installation of the packag dependancies it will try to execute the script.sh file but got error "FILE NOT FOUND! "

Tried:

  1. Not want todo git clone inside docker continer
  2. Not want to store source code inside the continer

So, how to map the host OS file to the container at build time

Or B
  • 1,675
  • 5
  • 20
  • 41
Dhairya
  • 743
  • 2
  • 11
  • 29

1 Answers1

2

you lack some COPY or ADD in your Dockerfile in order to copy your script.sh in your image.

Check the docs

https://docs.docker.com/engine/reference/builder/#add

https://docs.docker.com/engine/reference/builder/#copy

By the way, Docker is about isolation, so a running container should be isolated from the host, and certainly not access the host OS.

user2915097
  • 30,758
  • 6
  • 57
  • 59
  • Thanks #user2915097, Using ADD and COPY its will work but these have limitation like `ADD obeys the following rules: The path must be inside the context of the build; you cannot ADD ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.` – Dhairya Nov 02 '17 at 05:12
  • HI I posted new question related to this https://stackoverflow.com/questions/47067944/how-to-access-the-hosts-machines-localhost-127-0-0-1-from-docker-container/47068162#47068162 – Dhairya Nov 02 '17 at 06:57
  • Famous Vonc answered – user2915097 Nov 02 '17 at 07:09