
The -p flag is used to expose the container’s internal port to the host. Next, we can run a container derived from our image: > docker run -p 5000:22 -i -t ubuntu-vs /bin/bash We can then build an image based on our Dockerfile by running the following command from the directory where your Dockerfile is saved: > docker build -t ubuntu-vs. RUN echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config & \ # configure SSH for communication with Visual Studio RUN apt-get update & apt-get install -y g++ rsync zip openssh-server make

LABEL description="Container for use with Visual Studio" Use your favorite text editor to create a file called ‘Dockerfile’ with the following content. CMake is also a required dependency but I will deploy statically linked binaries directly from Visual Studio in a later step.

The following Dockerfile can be used to install Visual Studio’s required build tools and configure SSH. See Dockerfile reference for more information on authoring your own Dockerfiles. Dockerfiles contain the commands used to assemble an image and allow you to automatically reproduce the same build environment from any machine.

Next, we’ll use a Dockerfile to create a custom image based on our local image of Ubuntu. You can see a list of your docker images by running: > docker images This will download the latest image of Ubuntu from Docker. From the Windows command prompt run: > docker pull ubuntu We’ll get started by pulling down an image of the Ubuntu OS and running a few commands. See Install Docker Desktop on Windows for download information, system requirements, and installation instructions. You will need to download the Docker Desktop Client for Windows and create a docker account if you haven’t already. Set-up your first Linux docker containerįirst, we’ll set-up a Linux docker container on Windows. This workflow leverages Visual Studio’s native support for CMake, but the same instructions can be used to build a MSBuild-based Linux project in Visual Studio.

If you’re interested in learning more about Docker as a tool to configure reproducible build environments, check out our post on using multi-stage containers for C++ development. This post focuses on creating your first docker container and building from Visual Studio. In this blog post we’re going to use Visual Studio’s native CMake support to build a simple Linux application in a Linux docker container over SSH. This is especially useful for C++ cross-platform developers because you can target a container that runs a different operating system than the one on your development machine. The virtualized OS, file system, environment settings, libraries, and other dependencies are all encapsulated and shipped as one image that can be shared between developers and machines. Docker containers provide a consistent development environment for building, testing, and deployment.
