13
11988

How to run Ubuntu on Mac with Docker

Reading Time: 2 minutes

Experimenting with different OS or software is good but we sometime wonder how to experiment without risking our original machine system. Thus, we can run OS like Ubuntu on Mac with Docker.

With docker, we will be able to run system in containers that will be isolated from your machine environment. Thus, experimenting inside a container will not affect the external environment unless it is configured to linked to the host machine.

Let’s drill in to the step to get your Ubuntu on Mac running.

Install “Docker Desktop for Mac”

First, we will install docker application into our Mac machines. Visiting the link below will bring you to a page to download the installer in dmg format.

https://hub.docker.com/editions/community/docker-ce-desktop-mac/

Installing is as easy as dragging the file to the Applications folder and starting the application

Wait until your docker application is running. It will take a while if your machine is running other applications.

Get Ubuntu image from Docker Hub

There are different version of ubuntu docker image you can choose. For different versions, you can check out at this link. In this tutorial, we will install the bionic version which is ubuntu 18.04.

docker pull ubuntu:bionic

Run Ubuntu on Mac in container

To start a container running, we run the below command

docker run ubuntu:bionic

To check that the container is running and get the information, we run the below command

docker ps

You should see some information like the ones below

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
febc92bf017f        ubuntu:bionic       "/bin/bash"         8 seconds ago       Up 7 seconds                            condescending

Go into the container

To go into the bash environment of the container, we run the below command. Take note that the command needs to contain the name of the container.

docker exec -it condescending bash

After this step, you have entered into the ubuntu operating system. Feel free to do the things things that you want to try. If something doesn’t work out, we can destroy this container and restart from step 3 to launch a new container.

Conclusion

In conclusion, docker containers really helps us to have some form of environment that we can quickly launch and destroy. It gives more flexibility to experiment code or commands that we want to try without having to risk damaging our system.

Show Comments

No Responses Yet

Leave a Reply