'Can I build a Docker container from the CLI against a remote daemon?

Currently I've the following setup:

  • An Hyper-V VM running Windows 10 on which is my dev machine. My CPU doesn't support nested virtualization.
  • Docker for Windows is installed on the host machine which runs Windows 10 too.

Is it possible to run docker build from the VM against Docker on the host machine?



Solution 1:[1]

Yes, you can. According to the documentation, there is 3 ways to do this,

# with Git repo
docker -H xxx build https://github.com/docker/rootfs.git#container:docker

# Tarball contexts
docker -H xxx build http://server/context.tar.gz

Text files
docker -H xxx build - < Dockerfile

When doing this, you need to make sure that,

  1. your client have docker installed.
  2. all the dependent files are accessible by the host.

At the end, the docker image will be created in your host.


Update

the docker options is documented here now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1