Skip to content

Instantly share code, notes, and snippets.

@ghadj
Last active November 17, 2024 09:34
Show Gist options
  • Select an option

  • Save ghadj/f0834f808e6b666d553be685b819276b to your computer and use it in GitHub Desktop.

Select an option

Save ghadj/f0834f808e6b666d553be685b819276b to your computer and use it in GitHub Desktop.
A clean Docker linux dev environment without all the associated heaviness of a virtual machine.

Docker based Ubuntu dev environment

A clean linux dev environment without all the associated heaviness of a virtual machine.

Usage

  1. Ensure you have docker installed and running
  2. Clone this repo
  3. Open terminal and run, chmod +x build.sh
  4. And run chmod +x run.sh
  5. Run ./build.sh
  6. Run ./run.sh

This should give you a linux prompt for a user called "devuser" with password "passwd". This user is a sudoer.

docker build --rm -f Dockerfile -t ubuntu:project .
FROM ubuntu:latest
ARG BUILD_DATE
# Labels
LABEL maintainer="maintainer <email>"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL description=""
# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y sudo curl git-core zsh wget vim && \
adduser --quiet --disabled-password --shell /bin/zsh --home /home/devuser --gecos "User" devuser && \
echo "devuser:passwd" | chpasswd && usermod -aG sudo devuser
USER devuser
ENV TERM xterm
# Set and copy work directory
WORKDIR /Project
COPY ./Project .
CMD ["zsh"]
# Create directory on host and setup permissions
# (assuming 1000:1000 is the UID:GID of the user in contatiner)
mkdir ./Project
chown 1000:1000 "$(pwd)/Project"
# Run docker
docker run --rm -v "$(pwd)/Project":/Project -it ubuntu:project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment