Can I use docker to install ubuntu on Mac?

I use a Mac, but I want to learn and use Ubuntu for development, and I don't need a GUI. I used to use Vagrant and ssh for a machine, but it consumes most of my machine resources. Can I use docker for the same purpose and also have isolation (when I ruined things) of the virtual machine?

+7
docker
source share
3 answers
  • Install Docker for Mac first .
  • Then in the terminal window run: docker run -it --name ubuntu ubuntu bash

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

To get started after rebooting:

 docker start ubuntu docker exec -it ubuntu bash 

If you want to save the changes:

 docker commit ubuntu docker images 

See unnamed image and:

docker tag <imageid> myubuntu

Then you can start another container using the new image.

docker run -it --name myubuntu myubuntu bash

Or replace the old one

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

Hope this helps

+9
source share

This is one of the few scenarios that I would not use Docker for:

Base images like Ubuntu are heavily separated by full OS versions. Ubuntu's latest image lacks basic tools like ping and curl - this is Canonical’s focused strategy to minimize image size and therefore attack vector. As a rule, you should create an image to start one application process in the container, you would not use SSH and do not use the usual tools for developers, so they are not needed. This will make it difficult for you to learn Ubuntu, because there are not a lot of basic things there.

On a Mac, the best VM tool I used was Parallels - it manages to split the CPU without battery impact. VirtualBox is also good, and for any of them you can install the full Ubuntu Server from an ISO drive - 5GB and 1 GB of RAM will be much if you just look around.

With any hypervisor, you can pause virtual machines so that they stop using resources, and check them to save the image so that you can return to it later.

+6
source share

Yes, you can.

Try to find a docker hub for ubuntu containers of your choice (version and who supports the image)

Most of them are very well documented regarding what was used to create it, as well as how to start and access / open resources, if necessary.

Check out the official one here: https://hub.docker.com/_/ubuntu/

+3
source share

All Articles