Executando containers continuamente
Last updated
Last updated
$ docker container run nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
e4fff0779e6d: Pull complete
2a0cb278fd9f: Pull complete
7045d6c32ae2: Pull complete
03de31afb035: Pull complete
0f17be8dcff2: Pull complete
14b7e5e8f394: Pull complete
23fa5a7b99a6: Pull complete
Digest: sha256:447a8665cc1dab95b1ca778e162215839ccbb9189104c79d7ec3a81e14577add
Status: Downloaded newer image for nginx:latest
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/08/15 21:43:00 [notice] 1#1: using the "epoll" event method
2024/08/15 21:43:00 [notice] 1#1: nginx/1.27.1
2024/08/15 21:43:00 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/08/15 21:43:00 [notice] 1#1: OS: Linux 5.15.146.1-microsoft-standard-WSL2
2024/08/15 21:43:00 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/08/15 21:43:00 [notice] 1#1: start worker processes
2024/08/15 21:43:00 [notice] 1#1: start worker process 29
2024/08/15 21:43:00 [notice] 1#1: start worker process 30
2024/08/15 21:43:00 [notice] 1#1: start worker process 31
2024/08/15 21:43:00 [notice] 1#1: start worker process 32
2024/08/15 21:43:00 [notice] 1#1: start worker process 33
2024/08/15 21:43:00 [notice] 1#1: start worker process 34
2024/08/15 21:43:00 [notice] 1#1: start worker process 35
2024/08/15 21:43:00 [notice] 1#1: start worker process 36
2024/08/15 21:43:00 [notice] 1#1: start worker process 37
2024/08/15 21:43:00 [notice] 1#1: start worker process 38
2024/08/15 21:43:00 [notice] 1#1: start worker process 39
2024/08/15 21:43:00 [notice] 1#1: start worker process 40
2024/08/15 21:43:10 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:10 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:11 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:12 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:20 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:20 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:20 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:20 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
2024/08/15 21:43:21 [notice] 1#1: signal 28 (SIGWINCH) received
O terminal ficou preso!
Execução do container em modo detached (segundo plano):
$ docker container run -d nginx
3a6870fc609d4fce898d42d780b000f4896fb182a5cb92f11efd06256c21d180
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a6870fc609d nginx "/docker-entrypoint.…" 13 seconds ago Up 13 seconds 80/tcp naughty_benz
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a6870fc609d nginx "/docker-entrypoint.…" 52 seconds ago Up 52 seconds 80/tcp naughty_benz
Abrir o endereço http://localhost no navegador não funcionará. O container é executado de forma isolada.
Execução de uma instrução dentro do container:
$ docker exec -it 3a6870fc609d /bin/bash
root@3a6870fc609d:/# curl http://localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Será iniciada a sessão de terminal interativa do contêiner. O prompt de comando mudará para refletir que está dentro do contêiner. A partir daí, pode-se executar comandos Linux como se estivesse em um servidor normal. Por exemplo, pode-se navegar pelo sistema de arquivos, instalar pacotes, modificar arquivos de configuração, verificar logs, etc.