Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use docker for installing ubuntu on a Mac?

Tags:

docker

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?

like image 652
HorusCoding Avatar asked Oct 18 '16 15:10

HorusCoding


People also ask

Can you run Linux on Mac with Docker?

The answer is "Docker [Desktop] for Mac" does run a Linux host VM with a replacement for boot2docker - LinuxKit developed and maintained by Docker for the purpose of making lightweight distributions.

Can I install Ubuntu in Docker?

Install from a package Go to https://download.docker.com/linux/ubuntu/dists/ , choose your Ubuntu version, then browse to pool/stable/ , choose amd64 , armhf , arm64 , or s390x , and download the . deb file for the Docker Engine version you want to install.

Is Docker compatible with Mac?

Docker Desktop currently supports macOS Catalina, macOS Big Sur, and macOS Monterey. At least 4 GB of RAM. VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop.

Can I run Docker locally on Mac?

Before You Install On an “out-of-the-box” Linux installation, the Docker client, daemon, and all containers run directly on localhost, meaning you can access ports on a Docker container using localhost addressing; something like localhost:8080 or 0.0. 0.0:8376 . On macOS, Docker's daemon runs inside a Linux VM.


1 Answers

  • 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

like image 136
Carlos Rafael Ramirez Avatar answered Oct 05 '22 00:10

Carlos Rafael Ramirez