[DOCKER] A note that I had trouble when trying to use nginx with Remote-Containers of vscode

What I tried to do

Wai "Try developing an app with ** vscode Remote-Containers ** and ** Docker **. First from ** nginx **. ** I don't know Remote-Containers, Docker, or nginx at all ** but somehow Naruyaro "

What happened

Prepare the following yml and confirm that index.html prepared separately at localhost: 8080 is displayed by docker-compose up -d.


version: '3.8'
    image: nginx
      - .:/usr/share/nginx/html
      - "8080:80"

However, when I open the same one with Remote-Containers of vscode, index.html is not displayed even if I access localhost: 8080.

The command: / bin / sh -c" while sleep 1000; do :; done " line is written by default in the ./.devcontainer/docker-compose.yml that is automatically created when Remote-Containers is executed. However, it seems that index.html will not be displayed if there is this line.

Remote-Directory structure after running Containers

.devcontainer/          # Remote-Automatically generated by executing Containers
  docker-compose.yml    #This guy has a command line


I do not understand....

Start the nginx container with docker-compose.yml withoutcommand: / bin / sh -c "while sleep 1000; do :; done", attach it and hit the same sleep command and it will be executed properly ( (Log below), so it seems that there is no error in the command command: in the container.

[email protected]:/workspace# /bin/sh -c "while sleep 1000; do :; done"
[email protected]:/workspace# 

Somehow suspicious

When I tried docker ps --no-trunc, the COMMAND when I did docker-compose up -d manually was /docker-entrypoint.sh nginx -g'daemon off;' That thing. Is this overwritten by / bin / sh -c" while sleep 1000; do:; done "?

web_tmp > docker-compose up -d
Creating web_tmp_web_1 ... done
web_tmp >
web_tmp > docker ps --no-trunc
CONTAINER ID                                                       IMAGE               COMMAND
 CREATED             STATUS              PORTS                  NAMES
8f7c7a3300bd7e9894f387b39cc904776858893e337f849ecee5dd69e6ad9291   nginx               "/docker-entrypoint.sh nginx -g 'daemon off;'"  
 2 minutes ago       Up 2 minutes>80/tcp   web_tmp_web_1
web_tmp > 


When I set command: /docker-entrypoint.sh nginx -g'daemon off;' in docker-compose.yml, ╩╗index.html` was displayed. This is the cause!

It seems that the nginx daemon did not start as a result of overwriting docker-entrypoint.sh, which is implicitly executed by default, with another command. I solved it for the time being! Yay! !!


--Event: index.html disappears when there is command: / bin / sh -c" while sleep 1000; do :; done " in docker-compose.yml of nginx --Cause: COMMAND when starting the nginx container is from the default (= / docker-entrypoint.sh nginx -g'daemon off;') / bin / sh -c"while sleep 1000; do: Because it is overwritten by done " --Corrective action: Comment out command: from all docker-compose.yml. (Alternatively, use command: /docker-entrypoint.sh nginx -g'daemon off;'. Normally, that's not the case.)


Recommended Posts

A note that I had trouble when trying to use nginx with Remote-Containers of vscode
A note of someone who stumbled when trying to create a Rails project
[Note] A list of commands that I checked many times after trying Ruby.
A note that I gave up trying to make a custom annotation for Lombok
When I tried to use a Wacom tablet with ubuntu 20.04, I didn't recognize it.
A memo that I was addicted to when making batch processing with Spring Boot
A story that I had a hard time trying to build PHP 7.4 on GCE's CentOS 8
A warning is displayed when trying to use a huge integer with the special variables $ 1, $ 2, $ 3 ...
I was angry with proc_open (): fork failed when trying to composer update inside a Docker container
A story that I struggled to challenge a competition professional with Java
I want to make a button with a line break with link_to [Note]
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
A story that I wanted to write a process equivalent to a while statement with the Stream API of Java8
[Java beginner] I got a little deeper understanding of "It's time to use new", so make a note
I tried to make a Web API that connects to DB with Quarkus
Hanashi stumbled a little on path trying to study Java with VScode
I want to use DBViewer with Eclipse 2018-12! !!
Error when trying to use heroku command
I tried to implement a function equivalent to Felica Lite with HCE-F of Android
What I tried when I wanted to get all the fields of a bean
Volume that wants to use a lot of logical operators in if statements
When is it said that you can use try with a Swift error?
Rails6 I want to make an array of values with a check box
SpringSecurity I was addicted to trying to log in with a hashed password (solved)
I tried to clone a web application full of bugs with Spring Boot
I managed to get a blank when I brought the contents of Beans to the textarea
A story that I was really into when I did triple DES with ruby
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
I want to use java8 forEach with index
A collection of RSpecs that I used frequently
I tried to break a block with java (1)
[Ruby] I want to make a program that displays today's day of the week!
Since I use it often, I make a note of DB related things on Android.
What I was addicted to when developing a Spring Boot application with VS Code
[Solution] A memo that I had a hard time because the format of sinatra-validation changed
A story about PKIX path building failed when trying to deploy to tomcat with Jenkins
A site that was easy to understand when I was a beginner when I started learning Spring Boot
A story that failed when connecting to CloudSQL by running Sprint-boot with kubernetes (GKE)
I want to use PowerMock in a class that combines parameterized tests and ordinary tests
A story that stumbled when deploying a web application created with Spring Boot to EC2
I got an error when trying to install sbt to build a Scala development environment
A story that did not work when trying to handle events in Notification Center
What I was addicted to when trying to properly openAPI/Swagger documentation with Rails + Grape + Grape Swagger
A story I was addicted to when getting a key that was automatically tried on MyBatis
Summary of how to use the proxy set in IE when connecting with Java
Java: A story that made me feel uncomfortable when I was taught to compare strings with equals for no reason.
kintone clone? I was quite addicted to launching OSS WebDB Extension with Lightsail + Docker, so make a note of it.
How to deal with SQLite3 :: BusyException that occurs when uploading a large number of images using ActiveStorage in seeds.rb etc.