r/docker • • Mar 14 '21

Docker & Dockerfile Security Cheat Sheet

287 Upvotes

13 comments sorted by

13

u/uselessmlm Mar 14 '21 edited Mar 14 '21

Thanks, this is a great set of bookmarks for reference.

One question - I understand /var/run/docker.sock should never be exposed in a docker run or compose file. However, container management tools like Portainer need this to function.

So the only solution to this is to assume the additional risk and enable access?

9

u/StackIOI Mar 14 '21

You could use docker-socket-proxy for all other containers needing to access the docker.sock. With docker-socket-proxy you could have some control over what gets served over the socket, and you will only worry about one single container having direct access to the socket.

1

u/uncommonpanda Mar 14 '21

I was just thinking this myself... Is using Portainer a security risk?

4

u/LastSummerGT Mar 14 '21

I think that was always a known risk. You’re trading security for convenience.

1

u/Dergyitheron Mar 14 '21

What is the more secure and less convenient way to do what Portainer can do via the docker.sock?

1

u/LastSummerGT Mar 14 '21

I have no idea. I use Portainer too and I accept this risk.

2

u/Dergyitheron Mar 14 '21

Me too. I never really thought of any other way and noone really showed one. I guess this is just something you have to consider but there is nothing that would provide such convenience

0

u/mouthbuster Mar 15 '21

Kubernetes for life

1

u/PaintDrinkingPete Mar 14 '21

I’ve played around with Portainer in the past, but generally always just manage my containers and images via bash terminal...

2

u/Dergyitheron Mar 14 '21

Well, docker CLI is just a tool that is working with docker.sock. I mean if you need to manage docker from a container and exposing docker.sock is not considered secure what other way you have?

2

u/babuloseo Mar 15 '21

BOOKMARKED :3

1

u/[deleted] Mar 15 '21

Nice post!