[Note] How to restart the Windows container set up with docker-compose

Introduction

There was a time when I thought it didn't matter if I used Docker on Windows or Linux. Aside from the difference in behavior depending on the OS, it seems that there are differences depending on the containerization method. There are two main approaches to creating a container on Windows. One is to use Hyper-V and the other is to use Windows process isolation. I will omit the details, but it seems that the behavior of Docker (maybe only compose) is slightly different between the two, so I was addicted to the restart setting.

Thing you want to do

Enable docker-compose restart settings in the Windows Server container.

environment

OS:Windows Server 2019 Datacenter

problem

Docker has a restart option that allows you to set whether to start the container when the machine starts, but even if you ported docker-compose.yml that worked in the Linux environment to the Windows Server container as it is, it could not be restarted successfully.

Cause

When I checked the operating status around Docker at startup and restart, it turned out that the default network enabled when docker-compose was started disappeared at restart.

Countermeasures

It was solved by creating the network setting with nat external.

version: '3.5'

networks:
  default:
    external:
      name: "nat"

services:
  hoge:
    build:
      context: .
      dockerfile: ./hoge/Dockerfile
    container_name: hoge
    restart: always
    command: powershell
    stdin_open: true
    volumes:
      - .\hoge:C:\hogehoge

Finally

If you're in trouble, it's best to look at the official Microsoft documentation (https://docs.microsoft.com/en-us/virtualization/windowscontainers/).

Attention and disclaimer

The content of this article is my personal opinion, not the official opinion of the organization to which I belong. The author and the organization to which he belongs cannot be held responsible for any troubles that may occur to users or third parties after implementing the contents of this article.

Recommended Posts

[Note] How to restart the Windows container set up with docker-compose
How to set up a proxy with authentication in Feign
[Rails] How to speed up docker-compose
How to use MinIO with the same function as S3 Use docker-compose
[Note] How to get started with Rspec
How to set up and use kapt
[Java] How to set the Date time to 00:00:00
How to set JAVA_HOME with Maven appassembler-maven-plugin
How to monitor nginx with docker-compose with datadog
[Swift] How to link the app with Firebase
[Java] (for MacOS) How to set the classpath
How to set up and operate jEnv (Mac)
How to set up JavaED Full Edition (pleiades)
How to set up computer vision for tracking images and videos with TrackingJs
How to share on the host side (windows) and guest side (CentOS 7) with VirtualBox
How to change the action with multiple submit buttons
How to set the display time to Japan time in Rails
Organized how to interact with the JDK in stages
Use the --build-arg option of docker-compose to pass environment variables to the container built with Dockerfile
[Docker] How to see the contents of Volumes. Start a container with root privileges.
How to create docker-compose
How to set the retry limit of sidekiq and notify dead queues with slack
The story when the container does not start up with docker-compose up and an error occurs
I want to hit the API with Rails on multiple docker-composes set up locally
How to set up Android OR mapper "Orma" (Kotlin)
Summary of how to use the proxy set in IE when connecting with Java
The story that led to solving the error because postgres did not start with docker-compose up
Check how to set the timeout when connecting with Spring + HikariCP + MySQL and executing SQL
How to set environment variables when using Payjp with Rails
How to set chrony when the time shifts in CentOS7
Wait for the container service to start with docker healthcheck
Uppercase only the specified range with substring. (How to use substring)
[With back tricks] How to introduce React to the simplest Rails
How to deal with the error ERROR: While executing gem ... (Gem :: FilePermissionError)
I want to pass the startup command to postgres with docker-compose.
[Docker] How to access the host from inside the container. http://host.docker.internal:
How to change the file name with Xcode (Refactor Rename)
Set up GitLab with docker
How to set Docker nginx
[Note] How to write Dockerfile/docker-compose.yml
How to number (number) with html.erb
How to update with activerecord-import
How to set Java constants
[Docker] How to back up and restore the DB data of Rails application on docker-compose [MySQL]
How to set the IP address and host name of CentOS8
[Rails] How to introduce kaminari with Slim and change the design
To use the "java" command line tool ... How to avoid popping up
What I did when the DB did not start with docker-compose up
Try to set up Stanford CoreNLP Server for Windows (shortest guide)
How to scroll horizontally with ScrollView
[Rails] How to use devise (Note)
How to use the form_with method
How to get started with slim
How to find the average angle
[Java] Points to note with Arrays.asList ()
[Java] How to update Java on Windows
How to make a Java container
How to enclose any character with "~"
How to use the wrapper class
How to set Spring Boot + PostgreSQL
How to use mssql-tools with alpine