pycharm on windows and docker in linux vm - docker

By any chance can Pycharm on Windows be configured to run docker inside a linux VM (VirtualBox) ?
Meaning that i would like to take advantage of the Pycharm Docker tools of professional version but avoid installing docker for windows, since im using Linux VMs that have Docker installed.
Tried to set the tcp://xx.xx.xx.xx:2375 of the guest host vm but failing. Not sure if this can be done at all.

There's no native support, but you can configure PyCharm to work with remote Docker daemon. Basically you need a deployment configuration alongside the Docker-based remote interpreter to transfer the project files to remote machine where they can be mounted inside a container.
See the detailed instruction in PyCharm's bug tracker https://youtrack.jetbrains.com/issue/PY-33489 and please vote for the ticket if you want this support to be a first-class citizen in PyCharm.

Related

Detect Docker for Windows vs Docker Native inside of WSL2 VM

So I have a use case where I need to detect inside of a WSL2 VM whether the Docker setup is Docker for Windows w/ WSL integration vs Docker just running inside of the WSL VM (say installed directly via apt or dnf). The networking situation between these two use cases is different because with Docker for Windows WSL integration you cannot reach containers by their IP from the WSL VM. This poses some problems for some dev-tooling that we have and wasn't previously an issue with devs running on Linux-native machines but we've recently run into it now that some devs are using Windows machines with WSL and Docker for Windows.
Any thoughts on how I can do this? Look for specific env vars, mount points etc?
Looks like I can just stat /mnt/wsl/docker-desktop and see if that exists.

How to run Docker commands on remote Windows engine

I'm working on integrating Docker into our TeamCity build process so that I can create a task that runs a "docker build" to create an image from our code. Right now, all our build agents run on either Windows Server 2008 or Windows Server 2012, neither of which can run Docker. There's a chance we can get a license for one Windows Server 2016 build machine, but I'm wondering if there's a way to run Docker Engine on that machine while issuing docker commands from other build agents.
Here's what I've considered so far:
Docker Toolkit: This is a way to run Docker on legacy systems, but it spins up a local VirtualBox VM running Linux thus it can only run Linux containers. I need to be able to build and run Windows containers.
Docker Machine: This is a way to talk to a remote Docker engine. However, according to this open bug, it appears Docker Machine is only capable to talking to remote engines on Linux hosts due to security implementations; It's an old issue but I can't find any indication this limitation has been removed.
Docker itself uses a client/server architecture, but I couldn't find any documentation on how to talk to a remote engine without using something like Docker Machine.
Anything else I'm missing, or am I just pretty much out of luck unless we upgrade all our build agents to Windows 10 or Windows Server 2016?
You can start using the remote Windows Server 2016 instance from other build agents.
Docker allows to expose the Docker Engine (aka Daemon) via tcp. In that case and especially when the host is publicly reachable you should consider configuring authentication using client/server certificates. Details can be found in the official documentation at https://docs.docker.com/engine/security/https/, but you may find the Windows Server specific article at https://stefanscherer.github.io/protecting-a-windows-2016-docker-engine-with-tls/ more helpful.
Regarding your aspect of using a client to connect to a remote Docker Engine, please use the -H tls://<host>:<port> argument like described at https://docs.docker.com/engine/reference/commandline/cli/ (or see the example provided at https://stefanscherer.github.io/protecting-a-windows-2016-docker-engine-with-tls/#testtlsconnection).

Docker and specifying a target OS

I've read that:
Docker is a system for management and deployment of application containers, not operating system containers.
However, in several resources (e.g. around 1:20 into https://www.youtube.com/watch?v=pGYAg7TMmp0) it gives an example of "problems" you might encounter if you've developed a web application on a Windows PC or Mac, and are deploying it to a Linux server.
So, how does Docker help in this situation? If we take a web application I understand Docker could help you make a container with the source, and say a specific version of PHP. But could you specify a target OS for it to run on, if it's different from the server that Docker is running on?
The Docker FAQ (https://docs.docker.com/engine/faq/) says
You can run both Linux and Windows programs and excutables in Docker containers.
Does this mean you need Docker installed on a Linux and Windows machine separately to do this, or is it possible to specify any OS within your Docker image and have any machine run it?
Please can someone explain how - or if - Docker deals with specifying a particular OS for your application?
Docker started as a way to run containers on Linux hosts, and this remains the dominate target for docker containers. Developer environments include an embedded VM to run Linux under the covers on Mac and Windows. Originally this was VirtualBox, but newer releases use xhyve and hyperv. The host OS in all of these are Linux so you are not building your image on one OS and running it on another OS.
Since that start, Docker has expanded target OS's. This requires that you have a docker installation for that OS, and it requires that your image be designed to run on that architecture/OS. This started with other architectures of Linux like arm64, and now zLinux. The Microsoft partnership is a rather large rewrite, partially in Windows itself, but also in the Docker code, and especially in the images designed to run natively on Windows. To run these, you have to change the settings on Docker for Windows to run Windows containers instead of Linux containers, you cannot run them both concurrently on the same host. At present, running Windows binaries can only be done on a Windows host, Microsoft isn't shipping free VMs for Linux hosts. And as a new target platform, it still lags behind in features from the Linux hosts.

windows docker on vmwarevsphere

we use VMWare vSphere for VMs in our company.
To automatically create docker hosts we use one simple command:
docker-machine --driver vmwarevsphere .... vm params(cpu,memory,network,name, etc)
It automatically creates new VM machine in our VM cluster, installs docker and then we add it to swarm or create new.
Right now I need to create windows docker hosts to run windows containers.
Docker-machine installs boot2docker.iso after creating VM.
But instead I need VM with microsoft servercore or nano.
How do I do it?
Thanks a lot.
Anton
On a Windows machine with Docker for Windows installed you could run the following command to pull the official images for server or nanoserver
docker pull microsoft/nanoserver
or
docker pull microsoft/windowsservercore
I'm not exactly sure how you're automating this - are you using a dockerfile or docker compose?
Are you talking about setting up the Windows host that runs Docker engine? If so, Docker for Windows CE is meant to be desktop software so not recommended for server side workload. Also, Windows EE Server requires Windows Server 2016 or later. If you would really like to use Windows server core mode, Windows Server 1709 offers that. Still, it quite bit new, so you should not set high expectations just yet.
As per the instruction to install the engine, MS has this.
https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/quick-start-windows-server
Or, equivalent one from Docker here.
https://docs.docker.com/engine/installation/windows/docker-ee/
you are talking about hosting a windows container on VMware vSphere? I don't think this is possible right now, may be in the future. I have no documentation or link to verify my answer but in our company we have a similar situation and use vSphere for VMs and Linux container and Hyper-V in parallel for VMs and windows container.

How to run Google Datalab locally?

How do I run Datalab locally when it requires Docker (and Docker Toolbox is not supported as documented here: https://cloud.google.com/datalab/docs/quickstarts/quickstart-local)? The Docker website says Docker requires Windows 10 Professional or Enterprise 64-bit, and most corporate environments don't run Windows 10.
Docker is highly preferred over Docker Toolbox, as its a simpler, self-contained installation, with simpler configuration (since you don't have additional virtualization software to deal with, as you do with Docker Toolbox - namely boot2docker and its underlying functionality). However if you have a setup to run docker on your end, you should theoretically be able to use that for running the Datalab docker container by adapting the instructions.
You do have the option of running everything on a GCE VM.
I was facing the same problem, what I found more comfrotable in the end is to install Ubuntu on Virtual Box. This is free and fairly easy, and from the virtual machine you can use all the Docker and the Google guide to run Datalab locally.

Resources