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 "
Prepare the following yml and confirm that index.html prepared separately at localhost: 8080 is displayed by docker-compose up -d
.
docker-compose.yml
version: '3.8'
services:
web:
image: nginx
volumes:
- .:/usr/share/nginx/html
ports:
- "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
devcontainer.json
docker-compose.yml #This guy has a command line
docker-compose.yml
index.html
command: (abbreviated below)
is written in ./docker-compose.yml
.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.
root@hoge:/workspace# /bin/sh -c "while sleep 1000; do :; done"
^C
root@hoge:/workspace#
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 0.0.0.0:8080->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