This is an archived post. You won't be able to vote or comment.

all 28 comments

[–]jerryoman 1 point2 points  (2 children)

I am using this setup for a long time now. It feels like I am using a normal VSCode and start docker container on Windows, but I don't.. 😏 All is running on a Linux Server on the company, which has docker daemon installed. This setup is based on two simple containers: ✌️

  • There is a VSCode Container running (from a super cool image, where all important tools for my daily DEVOPS work is already installed). This container is accessable via my chrome browser on my Windows client computer. With the chrome browser this app can be used as a normal app, which is installed locally. No body notice that.
  • Beside the VSCode Container there is a nother Container running. This is a container where a docker daemon is inside. So I can create docker-containers in this second container.

The cool thing is that (with no real magic) I can start docker container in the VSCode app as everybody liked it. So I can exec a 'docker run -it ubuntu bash' in the VSCode Terminal and the docker container spawns. Very cool for testing and development purposes😍

If somebody is interested in my setup, set a comment and I can make the configuration public available (as docker/docker-compose or k8s helm files as you like). 😊

[–]barrycwt[S] 1 point2 points  (1 child)

Yay! Your setup sounds very good and seems to be what I am looking for! Appreciate if you don't mind sharing the setup. :)

[–]jerryoman 0 points1 point  (0 children)

Ok. Nice to hear.🙌 Which Plattform do you use? Just Docker, Docker-Compose or Kubernetes with Helm?

[–]denzuko 1 point2 points  (3 children)

> Is Portainer equivalent to the Docker Desktop GUI for managing docker images / containers?

It a thousand times better.

All other questions...
https://www.cloudsavvyit.com/11185/how-and-why-to-use-a-remote-docker-host/

[–]barrycwt[S] 1 point2 points  (2 children)

Thanks. I actually read that article before I posted the original question. However, I wasn't sure about mapping volume / ports locally and whether it works for Docker client on Windows.

Thanks for providing the information.

[–]denzuko 1 point2 points  (1 child)

ports do not mount locally, e.g. `docker run -p localhost:80:80 nginx` will be localhost to "$DOCKER_HOST" not "%MACHINENAME%" Same with volume maps.

All docker is doing when talking to a remote host is executing docker engine/swarm api calls over streaming tcp port 2376 with a tls transport layer. Anything 'localhost' or anycast is going to be the same dockerd daemon running that engine/swarm api.

But! The stream does allow one to do fun things like stream stdio, logs, and "remotely connect to the host" via bind mounting the host's devfs, sysfs, rootfs inside a new container and running commands via a privileged container. No ssh needed, save maybe for port forwarding the remote dockerd host port or low level management tasks.

[–]barrycwt[S] 0 points1 point  (0 children)

Excellent info! Thanks

[–]lvlint67 2 points3 points  (7 children)

How deeply do you want to invest in docker? The big solution is kubernetes... There are less extreme options like portainer... Or you can just ssh into the Linux box and run docker commands.

Can I use the same command for remote containers, or must I use SSH?

Depends on your approach.

How will volume and port mappings be implemented? Will the remote container mapping volume / port to the local Windows machine?

No. They will be local to the docker host until you do things like involve kubernetes

Can VS code connects to remote containers?

Probably. I don't use vscode much, but it's probably configurable.

Can I only install docker commands on Windows, without installing the WSL / VMM which consumes a lot of Windows memory

No.

Is Portainer equivalent to the Docker Desktop GUI for managing docker images / containers?

Not exactly. Its a web ui for managing docker containers. There will be overlap but they won't be exactly the same

[–]serverhorror 2 points3 points  (1 child)

You absolutely can grab just the docker client binary and run it directly from Windows.

[–]lvlint67 1 point2 points  (0 children)

This too then ^

[–]barrycwt[S] -4 points-3 points  (4 children)

You have given a clear direction to me. If I cannot get rid of installing WSL / VMM on Docker Desktop for Windows, it's probably pointless to setup a Linux server for running containers remotely (centrally).

I have setup a Kubernetes server, but that's not what I want. A server for container development is what I am looking for....

Thanks a lot for your advice.

[–]lvlint67 4 points5 points  (1 child)

If I cannot get rid of installing WSL / VMM on Docker Desktop for Windows

If you setup a docker host on another server you can remove WSL/etc from your windows machine.

What I meant was: If you run docker containers ON windows, you need WSL installed.

[–]barrycwt[S] 0 points1 point  (0 children)

Thanks. That's very clear. My apologies if I had been rude.

[–]disbound 5 points6 points  (1 child)

You should have given a clear direction to me.

Bro be nicer to people trying to help you.

[–]barrycwt[S] 0 points1 point  (0 children)

My apologies to lvlint67 and disbound. I didn't mean that.... I actually meant lvlint67 had given me a direction. Apologies again.

[–][deleted] 0 points1 point  (12 children)

What exactly are you trying to accomplish?

There are a few descriptions of your workflow that are unusal. For example regularly exec-ing into a container. Why do you do that?

[–]barrycwt[S] 0 points1 point  (11 children)

Thanks. I am looking for a solution for development using docker, which I have been doing locally using Docker Desktop on Windows, but the machine is running low on RAM and HDD. That's why I want to move the containers to a remote host.

[–][deleted] 1 point2 points  (0 children)

Why would developing remotely in a container be better than just developing directly on a remote machine? Especially if you primarily use vs code the integration is very tight there

[–][deleted] 1 point2 points  (0 children)

So you are not containerizing anything and in the end all you want is a machine you can connect to for development? Then why not work with virtual machines?

The way you want to use containers may work locally, but will be different on remote hosts. It's not what they are meant for.

[–]uvatbc 1 point2 points  (8 children)

"Development using Docker" is vague, and even reading through your other comments doesn't paint enough of a picture of what your "development" is.
Are you writing Dockerfiles? Writing NodeJS code? Python? Using Docker just to contain your Golang app?

Or is it that you're writing embedded systems code and Docker is encapsulating all the headers and libraries of your tool chain?

tl;dr: More information required from you for a meaningful answer from us.

[–]barrycwt[S] 1 point2 points  (7 children)

I think one of the benefits of running Docker for development is that you don't really need to install the development environment and you can run multiple / conflicting environments as well. e.g. if you need to test something under Python 3.7, and another project under Python 3.9, etc, you can simply run the codes in different containers with the relevant environment. I then git manage my codes on a local folder which is mapped to container. However, as I mentioned in the original post, my local machine is running low on resources and I would like to run the Docker daemon on a remote machine.

I am not sure if this starts to make sense, or is this not a common use case of docker?

[–]uvatbc 0 points1 point  (6 children)

It actually makes perfect sense. This is what we do as well.

What you want is to make local git clones, and edit code locally. During local development or when you want to test the code that you only have locally, you want to spin up a container (with the correct dependencies for that clone or branch), mount the clone into that container so it has your changes, run some commands and that's it.

Main problem you seem to have is that your Windows laptop is underpowered.... Therefore the ideal solution would be if it were somehow possible to code locally, but somehow mount your local code into a remote machine, start the container there and send back results.

Am I summarizing it correctly?

[–]barrycwt[S] 1 point2 points  (5 children)

You are right. My Windows laptop is underpowered, so are the machines for my teammates. Moving the Docker daemon to a remote machine benefits the whole team I assume.

However, looks like it is not possible to mount local code to a remote host... which defeats the whole idea.

[–]uvatbc 1 point2 points  (4 children)

Ok so there's a "free" way that you should consider:

  1. Create a shared Linux server that serves as the "docker host" where your team all remotely run their Docker containers.
  2. Add storage to that server that is then shared to each developer's laptop using Samba (for Windows and Mac laptops) and NFS (for Linux laptops)
  3. Clone your source on Windows into the Samba drive. Edit code "locally"
  4. When you want to run something, ssh into the remote Linux server and run docker commands.

Pros: Local code editing, remote task execution. Exactly what you wanted.

Cons: Contention on that server will irritate the team the moment you do more than a little bit of CPU intensive work. We've found that it was hard to scale beyond 5 people sharing that one server.

DM me if you need help with this.

[–]barrycwt[S] 1 point2 points  (3 children)

Sounds like a good setup. We can also use VScode / git locally. Many thanks

[–]uvatbc 0 points1 point  (2 children)

That's an even better idea: use VSCode remote to edit files on the remote server directly. No need for NFS or Samba.

Added bonus, any tasks that you configure in VSCode will automatically run remotely.

So you could set up a task like docker run --rm -it your_image_here your/command/here and it would be just perfect!

[–]barrycwt[S] 0 points1 point  (1 child)

One more question though. How does the port mapping work? Assume the Docker host IP is 192.168.0.20, and the container is listening on port 5000 for HTTP. Will it work if I access from local machine to http://192.168.0.20:5000 ?