Configuring a Docker in 5 Minutes
Using the Command Line
This article shows how to configure Docker containers the easy (yet probably wrong) way. It is great for beginners to play around with Docker. The only knowledge you need is the Linux command line. No need to learn the Dockerfile script syntax. The Docker we configure is based on Ubuntu, but the technique can be further extended. Finally, we assume that Docker is already installed. If not please refer to https://docs.docker.com/engine/install/
STEP 1/4: Run a Docker Container
In our case, we will be running an Ubuntu container. For this execute the following command:
$ docker run -it — name 5min ubuntu
This simple command will pop a bash shell from inside the container. Replace the [container_name] by the name of your choosing. In our case we will be using the name “5min” :
$ docker run -it — name 5min ubuntu
STEP 2/4: Configure your Container
Now that we access to the shell, we can configure our system as any brand new Linux system. You can for example use apt-get to install new packages.
For example, to install GNU screen:
$ apt update
$ apt install screen
Note that the “apt update” is important as the system is “new”.
STEP 3/4: Save the Container into an Image
Once the container is contained you can simply exit the bash. Then create an image from it:
$ docker commit [container_name] [image_name]
[container_name] will be 5min in our example. Let’s set image name to “i5min”:
$ docker commit 5min i5min
STEP 4/4: Run the New Image
To restart the container with all its configurations simply run:
$ docker run -it [image_name]
For our example, it will be i5min:
$ docker run -it i5min
Conclusion
That’s it! You can now build your container the easy way. You can even consider “pushing” it and sharing it ;)
Question: what is the difference between the command in STEP 1/4 and STEP 4/4?