Navigate back to the homepage

Docker on mac vs linux

Nancy Chauhan
April 20th, 2020 · 1 min read

🐳Docker is different on Mac and Linux systems. Docker directly leverages the kernel of the host system on Linux. On the other hand, Mac does not provide a Linux kernel, so Docker runs on a small Linux VM running on a mac. Due to this, there are many differences.

Cannot access container IPs directly

On Linux let’s try to inspect a running docker image :

1ubuntu@primary:~$ sudo docker ps
3a230855dd7d2 httpd "httpd-foreground" 17 seconds ago Up 16 seconds 80/tcp determined_saha
4ubuntu@primary:~$ sudo docker inspect determined_saha

Let’s curl the IP :

1"IPAddress": "",
2 "IPPrefixLen": 16,
3 "IPv6Gateway": "",
4 "GlobalIPv6Address": "",
5 "GlobalIPv6PrefixLen": 0,
6 "MacAddress": "02:42:ac:11:00:02",
7 "DriverOpts": null
8 }
9 }
10 }
11 }
13ubuntu@primary:~$ curl
14<html><body><h1>It works!</h1></body></html>

However on mac when hitting the IP address of the container we get :

1➜ curl
2curl: (7) Failed to connect to port 80: Operation timed out

Curl times out because the container is running inside the VM and not sharing the network with the mac.

More articles from Nancy Chauhan

Today I Learnt - Git Submodules

Today I learned how messy git submodules could be! 😾

April 16th, 2020 · 1 min read

Monitoring Java Web Apps using Prometheus and Grafana

Monitoring an application’s health and metrics makes it possible to manage it in a better way and notice unoptimized behavior.

April 15th, 2020 · 3 min read
© 2018–2020 Nancy Chauhan
Link to $ to $ to $ to $ to $