Daily: Build a Development Environment with Docker and VS Code



Working with different software (samples, compilers, demos) always requires an adequate environment.

Because i don’t want to pollute my normal environment (my running PC), i decided to use a virtual environment with Docker.

Luckily, VS Code supports this by using remote containers and working fully within these containers.

The Files


	"name": "Prolog Environment",

	"dockerComposeFile": [

	"service": "app",
	"workspaceFolder": "/workspace",

	"settings": {},
	"extensions": []


        context: .
        dockerfile: Dockerfile

    container_name: pws_prolog

        - ../workspace:/workspace:cached

    # Overrides default command so things don't shut down after the process ends.
    command: /bin/sh -c "while sleep 1000; do :; done"


# STAGE 1:
FROM ubuntu:latest as base_nodejs

# Configure Timezone
ENV TZ 'Europe/Berlin'

RUN echo $TZ > /etc/timezone 

RUN    apt-get update \
    && apt-get install -y tzdata \
    && rm /etc/localtime \
    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
    && dpkg-reconfigure -f noninteractive tzdata \
    && apt-get clean

RUN apt-get install --yes build-essential curl sudo git vim

# Create user
RUN    groupadd work -g 1000 \
    && adduser user --uid 1000 --gid 1000 --home /workspace --disabled-password --gecos User

# Setup sudo
RUN echo '%work        ALL=(ALL)       NOPASSWD: ALL' >/etc/sudoers.d/work

# Install Prolog
RUN  apt-get -y install swi-prolog

USER user

VOLUME [ "/workspace" ]
WORKDIR /workspace

CMD ["/bin/bash"]

The Explanation

The Latest