Creating a docker workstation

go back / p4p1


Created on Tue. 19 jan 2021



This blog post is going to focus on creating docker containers and working with them interactively. Before starting I want to explain docker in a brief sentence to get everyone up to speed. Docker is a software that helps you in creating namespaces inside of your computer so that you can work on projects in specific environments.

Namespaces are a linux kernel concept so when you run docker on MacOS or Windows you are in fact installing a linux virtual machine and then running docker hence WSL2 support on Windows 10 is needed.

Docker Basics

In docker there a two main concepts, 1. Containers & 2. Images. Containers are the heart of docker, this is where your environment or application is going to live in. Images are like the operating system of the container a bit like an iso image that you can boot of.

Installation

If you are on linux installing docker is very straight forward, here is the command:

          
             $ sudo pacman -S docker
          
        

Docker Files

Another very important concept about docker are docker files. Those are the files where you configure your docker container. It is here where you define your different images and specify which package to install. You can copy the different instructions to start. You will need to create a directory from which to work from.

          
            FROM archlinux:latest

            CMD ['/bin/bash']
          
        

The first line of the docker file uses the instruction FROM, this instructs docker which image you want to use for your container. The second line of the docker file is CMD, this instruction is used for defining the command that will be ran by the container on execution. In our case it is /bin/bash so that we can have an interactive shell.

Basic Commands

Now that you have built the docker file you can now focus on the good stuff. In your terminal inside of the directory of the docker file you will now want to build the container with the following command:

This command will setup the container for later use. You can now run the container in interactive mode. We want to run this container interactively because we are using bash as a command and we will want to input different commands inside of that shell to work with it, using the following command:

You can see the -it inside of the command the i part is used to specify the interactive mode and the t is used to setup a tty environment to work with the container.

Where to go from there?

Now that you can make a simple docker container to work with you can add different commands to the docker file to install different dependencies and such here is a simple template that you can mess around with that I built to showcase my work environment inside of a docker container (here).


Thank you for reading this and have a good day/night :)

Amazing resources to go further
Questions / Feedback
For any questions or feedback you can contact me on LinkedIn or twitter / X. I also use twitter as a platform to update on new posts!
Donate
sponsor me image

If you like the content of my website you can help me out by donating through my github sponsors page.