Mastodon hachyterm.io

Today I learned that you can’t bind-mount folders on your host machine into a Docker container during build.

For local development, I bind-mount with docker-compose.

Example:

version: '2.4'

services:

  url-shortener:
    build:
      context: ./services/url-shortener
      dockerfile: Dockerfile
    volumes:
      - './services/url-shortener:/usr/src/app:delegated'
    ports:
      - 5001:5000

My goal was to use the language’s package manager to install the required dependencies.

Here’s the Dockerfile:

## base image
FROM nimlang/nim:1.0.4-regular AS build-image

## set working directory
WORKDIR /usr/src/app

## install dependencies
RUN nimble refresh && nimble install -y

## run server
CMD nimble c -r src/urlShortener

Here is the problem: nimble can’t find the required files for installation. docker-compose mounted the local files into the container, but that doesn’t work during build.

Further Reading