How to share a docker network between LXC containers

WillSnake

New Member
Apr 22, 2023
2
0
1
Hello!
I don't have a lot of experience with Proxmox, but I was wondering if it's possible to share a docker network created with a docker-compose.yml between several LXC containers.
I'm not familiar with docker swarm, that's why I want to know if this is possible before trying to use it.
I know that LXC containers share resources from the host machine, that's why I was wondering if I can mount the /var/run/docker.sock into the LXC containers.
So far I've tried to mount the /var/run/docker.sock like this:

On the Proxmox host, create a new group for Docker:
Code:
groupadd -g 1000 docker_sock

Change the ownership of the Docker socket:
Code:
chown root:docker_sock /var/run/docker.sock

Modify the permissions of the Docker socket:
Code:
chmod 660 /var/run/docker.sock

Edit the LXC container's configuration file and add the following lines:
Code:
lxc.mount.entry: /var/run/docker.sock mnt/docker.sock none bind,create=file
lxc.idmap: u 0 100000 65536
lxc.idmap: g 0 100000 65536
lxc.idmap: g 0 100000 1000
lxc.idmap: g 1000 1000 1
lxc.idmap: g 65534 165534 1

And after these changes I got stuck, because I'm having issues with the permissions on the file mounted on mnt/docker.sock because I tried to create a symlink to /var/run/docker.sock inside the container.

Does anybody know if this is possible?

Screenshot 2024-07-11 at 11.30.03 a.m..png
 
the only way I can think to make this happen is if your docker containers connect to the same network your LXC containers are on via a MACVLAN set up in docker. Without a macvlan or ipvlan docker network, the normal brisdge networks won't allow it.
 
the only way I can think to make this happen is if your docker containers connect to the same network your LXC containers are on via a MACVLAN set up in docker. Without a macvlan or ipvlan docker network, the normal brisdge networks won't allow it.
Interesting. That's a good idea, I can give it a try. I'll let you know if I can make it work.
Thanks louie1961!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!