DEV Community

CK Dev
CK Dev

Posted on

How to use docker if you are using AWS windows workspace

Hi everyone,

I know many of you are struggling to get Docker working on your Windows AWS Workspace. One of the easiest and most reliable solutions is to connect your Workspace to a remote Docker host.

An EC2 instance is probably the simplest and most practical option. If your Workspace is running in a private VPC, launch an EC2 instance in the same VPC and install Docker on it.

Install Docker on Amazon Linux 2023:

sudo dnf update -y
sudo dnf install docker -y
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker ec2-user
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

docker version
docker run hello-world
Enter fullscreen mode Exit fullscreen mode

From your AWS Workspace, create a Docker context that connects to the EC2 instance over SSH:

docker context create workspace-ec2 \
  --docker "host=ssh://ec2-user@<EC2_PRIVATE_IP>"
Enter fullscreen mode Exit fullscreen mode

Switch to the new context:

docker context use workspace-ec2
Enter fullscreen mode Exit fullscreen mode

Verify that Docker commands are being executed on the EC2 instance:

docker ps
docker images
docker run hello-world

Enter fullscreen mode Exit fullscreen mode

You can check the active context at any time:

docker context ls
Enter fullscreen mode Exit fullscreen mode

To switch back:

docker context use default
Enter fullscreen mode Exit fullscreen mode

Some benefits of this approach:

No need to install or troubleshoot Docker Desktop on the Workspace.
Containers run on EC2, so Workspace resources remain available for development tools.
Better performance and scalability.
Works well with VS Code, IntelliJ IDEA, and other Docker-enabled IDEs.
Easy to upgrade by simply resizing the EC2 instance.

I've been using this setup successfully, and it has been far more reliable than trying to run Docker directly on a Windows AWS Workspace. If anyone is interested, I can also share steps for configuring Docker Compose, VS Code Remote Development, and IntelliJ integration with the remote Docker host.

Top comments (0)