I often need to test a specific Linux binary or make sure something works as expected from yum install
or apt install
.
To do this, it’s common to have a virtual machine lying around, or even a VPS that you can just quickly log into.
Things are a bit easier and quicker if you use Docker.
Let’s run two tests, the first one to get going with Ubuntu, and the second to get going with Centos.
Ubuntu in 30 seconds
Head over to your terminal and type the following:
mkdir -p ~/tmp/docker_testing/ubuntu && cd $_
Code language: Bash (bash)
Now create a file called Dockerfile
. We’ll stay in the terminal and use vi
to do this.
Code language: Bash (bash)vi Dockerfile
Now we will add the following line:
FROM ubuntu:latest
Code language: Dockerfile (dockerfile)
Now press ESC
, followed by :x
to save and exit vi
.
From the terminal window we can now build the Dockerfile:
Code language: Bash (bash)docker build -t ubuntu_test .
Now we can run bash directly on this container:
Code language: Bash (bash)docker run -it ubuntu_test bash
We are now dropped into the container as seen by the prompt:
Code language: Bash (bash)
We will now run an apt update
followed by the apt search <package>
that we want to install.
CentOS in 30 seconds
The setup for CentOS is pretty much the same as we did above for Ubuntu. However, if you weren’t paying attention, let’s run it again quickly:
mkdir -p ~/tmp/docker_testing/centos && cd $_
Code language: Bash (bash)
Create a Dockerfile
. As per usual, we will use vi
in the terminal to create our file.
Code language: Bash (bash)vi Dockerfile
Add the following:
FROM centos:latest
Code language: Dockerfile (dockerfile)
Now press ESC
, followed by :x
to save and exit vi
. Then let’s build and run our Docker image!
Code language: Bash (bash)docker build -t centos_test . docker run -it centos_test bash
We are now placed in our centos container as shown below:
[[email protected] /]#
Code language: Bash (bash)
You should now run a yum update
to make sure everything is updated before running any yum install <package>
[…] I often need to test a specific Linux binary or make sure something works as expected from yum install or apt install. To do this, it’s common to have a virtual machine lying around, or even a VPS that you can just quickly log into. Things are a bit easie… Read more […]