A dockerized Ubuntu 20.04 workspace template with Python 3.8 installed.
- GitHub: https://github.com/Jench2103/docker-base-workspace
- Docker Hub: https://hub.docker.com/r/jench2103/docker-base-workspace
In the GitHub repo, there is a script run which can help you manage the worspace easily. Note that if you are working on Windows systems, use the following commands in Bash-like shells such as Git Bash.
$ git clone https://github.com/Jench2103/docker-base-workspace.git
$ cd /path/to/docker-base-workspace
$ bash run
This script will help you manage the Docker Base Workspace.
You can execute this script with the following options.
pull : pull the latest official image from DockerHub
build : build a new image on this machine
build-registry : build images with specified platforms and push to DockerHub
start : pull and enter the workspace
stop : stop and exit the workspace
prune : remove the docker image
repull : remove the existing image and pull the latest one to apply new changes
rebuild : remove the existing image and build a new one to apply new changesbash run startUse this command to close and remove a running container.
bash run stopImport this image into your dockerfile with the following statement.
FROM jench2103/docker-base-workspacebash run buildTo remove an existing image for further rebuilding, use the following command. Note that this command will stop existing containers before removing images.
bash run prunebash run build-registry- The
bash run startcommand can perform different tasks for you depending on the actual situation.- First execution: Pull the Docker image, create a container, and enter the terminal.
- Image exists but no running container: Create a container and enter the terminal.
- Container is running: Enter the terminal.
- Users can put all permanent files in
~/projectsof the workspace, which is mounted todocker-base-workspace/projectson the host machine. - The container won't be stopped after type
exitin the last terminal of the workspace. Users should also usebash run stopcommand on the host machine to stop and remove the container.
This repository is a GitHub template. Feel free to create your own Docker Workspace repository by clicking the Use this template button, then customize the setup and configurations to meet your requirements according to the following descriptions. For the detail about GitHub template, see Creating a repository from a template.
docker-base-workspace/
├── Dockerfile
├── config/
│ └── requirements.txt
├── run
└── scripts/
├── .bashrc
├── login.sh
├── start.sh
└── startup.sh
- The User ID (UID) and Group ID (GID) of the default user in the container will be synchronized as host operating system.
- The User Name will be synchronized only if the image is built by your own machine.
- The Group Name would not be synchronized because some operating systems (e.g. MS Windows) does not have this information.
- System packages: Customize the
apt-get installcommands inDockerfile. Use flag-qqto make installation processes quiet and assumeyesfor questions by default. - Python packages: Add package names (and versions) into
config/requirements.txt.
scripts/start.sh: Execute when the container start, should be blocked before reach the end.scripts/login.sh: Execute whenever the user start new bash terminals, must make sure it can reach the end.scripts/startup.sh: Execute when the user type 'startup' anywhere in the container.