Can I use docker for installing ubuntu on a Mac?

docker

Solution

- First install Docker Desktop for Mac.

- Then in a terminal window run: `docker run -it --name ubuntu ubuntu:xenial bash`

You are in a terminal with ubuntu and can do whatever you like.

Note: If you are using an ubuntu version bionic (18.04) or newer (`ubuntu:bionic` or `ubuntu:latest`), you must run the command `unminimize` inside the container so the tools for human interaction be installed.

To start again after a reboot:

docker start ubuntu
docker exec -it ubuntu bash

If you want save your changes:

docker commit ubuntu
docker images

See the unnamed image and:

`docker tag <imageid> myubuntu`

Then you can run another container using your new image.

`docker run -it --name myubuntu myubuntu bash`

Or replace the former

docker stop ubuntu
docker rm ubuntu
docker run -it --name ubuntu myubuntu bash

Hope it helps

Problem

I'm using a Mac, but I want to learn and use Ubuntu for development and I don't care about the GUI. I used to use Vagrant and ssh to the machine, but it consumes much of my machine resources. Can I use docker for the same purpose while also having the isolation (when I mess things up) of a VM?

Original source