Run your Development Server on Docker Desktop on Windows

Start with the easiest case

Posted by Torsten Kleiber on March 22, 2022 / updated on January 18, 2023 Tags: Docker Docker-Desktop Infrastructure-as-Code Virtual-Development-Server Windows

In my series about Modern Infrastructure for your Virtual Development Server I will now start with the easiest case for me. I will run a Server on a Docker Desktop on Windows. As I need CI for all of my projects I will use Jenkins as example for this. See how this works.

Here you see the architecture overview:

virtual development server docker desktop on windows

At first you need to install Docker Desktop Windows.

Docker Compose is then already installed with Docker Desktop.

Next I create a Docker Compose file for my Jenkins server. To make it easy for this blog I will start only a standard Jenkins server, for this I use the most parameters from Jenkins documentation.

docker-compose.yml
version: '3.8' (1)
services:
  jenkins: (2)
    environment:
      - DOCKER_CERT_PATH=/certs/client
      - DOCKER_HOST=tcp://docker:2376
      - DOCKER_TLS_VERIFY=1
    image: jenkins/jenkins:lts-jdk17 (3)
    ports:
      - "8080:8080"
      - "50000:50000"
    restart: unless-stopped (4)
    volumes:
      - jenkins_data:/var/jenkins_home
      - jenkins_docker_certs:/certs/client:ro
volumes:
  jenkins_data:
  jenkins_docker_certs:
1 Compose file format should match to the Compatibility matrix.
2 Jenkins is the single service for our example.
3 I use the long term support Jenkins image with JDK 17 runtime.
4 The service should be started with Docker Desktop and in case of an error.

To give your Development Server component a unique name you can set the project name environment variable via the .env file.

.env
COMPOSE_PROJECT_NAME=project

From the directory of your files you can now use following commands to control your Development Server:

docker compose up --detach  &:: (1)
docker compose stop  &:: (2)
docker compose start  &:: (3)
docker compose down  &:: (4)
docker system prune --all --volumes --force  &:: (5)
1 Pull docker images, if not already done and create and start all services contained in docker-compose.yml.
2 Stop all services preserving state in docker volumes.
3 Start all services using state in docker volumes.
4 Destroy all services.
5 Delete all not used containers, images and volumes. Caution! Use this command only, if this is your only environment in Docker Desktop!

If you start your server you should see the following in the Docker Desktop Console:

virtual development server docker desktop on windows docker desktop

As your server is running you can now access it via localhost:8080:

virtual development server docker desktop on windows unlock jenkins

You can go now to Docker Desktop,

virtual development server docker desktop on windows jenkins password
1 open the container console
2 and get the password to further configure Jenkins from the browser.

In a later blog I will show you a ready configured Jenkins server via Infrastructure as Code.

You find all sources on GitHub.

That’s it!