DEV Community

Cover image for Using Docker & Installing a Linux Distro. + cURL
Joey Ohannesian
Joey Ohannesian

Posted on

Using Docker & Installing a Linux Distro. + cURL

Goal

The goal of this project is to use Docker to setup a Linux distribution and check the cURL version. This should be a fairly quick tutorial since Docker is awesome and can do everything in a few commands.

Prereqs

šŸ“Docker Engine & CLI installed
šŸ“Internet connection

Let's Get Started!

The first thing that we need to do is install the Linux distribution of our choice. I'm using Ubuntu 22.04. We're also going to install bash alongside the installation so that we can immediately start doing the commands we need to once inside.

docker container run --name ubuntu --rm -it ubuntu:22.04 bash

successful installation

Breaking It Down
  • --rm makes cleaning up easier. Once I exit the container, the container will be wiped clean and removed rather than just stopped.
  • --it is actually two commands that are combined.
  • -i actually is -interactive shortened and allows us to input directly into the container.
  • -t stands for -tty which allows us to interact with the shell within the container.

ubuntu logo
You don't have to use Ubuntu, but the commands in the next section are Ubuntu specific. If you're using a different Linux distribution, check the docs for your distro on how to download cURL.


See If cURL Works

At this point you should be in your Ubuntu instance. Let's try to run curl --version and see if we're all set!

curl not installed

It turns out that curl isn't installed by default in the Ubuntu 22.04 image. No problem, let's download it!

apt-get update && apt-get install curl

Breaking It Down
  • apt-get update updates the system's repositories so that everything will work correctly when calling apt-get install
  • && apt-get install curl -y runs the cURL installation right after apt-get update finishes

See If cURL Works... Now?

curl --version
version of curl

curl google.com
checking google with curl

Woohoo, time to celebrate!


Wrap Up

In this quick demo, I've shown how to use Docker to download and install cURL on a containerized Linux distribution. I am really coming to appreciate how quick and easy it is to work with Docker and am interested in seeing how I can utilize userdata with EC2 instances to make software installation a breeze.

Top comments (0)