Skip to content

Instantly share code, notes, and snippets.

@margaret
Last active August 22, 2018 18:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save margaret/ac79bbab2234143d08abf605e9eddad5 to your computer and use it in GitHub Desktop.
Save margaret/ac79bbab2234143d08abf605e9eddad5 to your computer and use it in GitHub Desktop.
Basic docker-compose with a volume, and bash entrypoint

Simple docker-compose setup

Simple example for creating a Docker image for development.

Structure:

/whales
  /foo
    ...
  docker-compose.yml
  Dockerfile

Running docker-compose build and then docker-compose run dev from inside the whales directory will run the container and then drop you into the src directory. Any files you have in the foo directory on your host machine will be shared with the foo directory in the container with git and emacs installed.

Can change the FROM image to some other Linux-based box that suits your application (python, node, jupyter, etc).

You have to do docker-compose run instead of docker-compose up if you want an interactive session, because up is meant to run multiple containers.

version: '3'
services:
dev:
build:
context: .
container_name: foo
volumes:
- ./foo:/src/foo
stdin_open: true
FROM debian:jessie
RUN mkdir /src
WORKDIR /src
RUN apt-get update --fix-missing && \
apt-get -y --force-yes install emacs git
ENTRYPOINT /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment