docker run
でコンテナ名を付ける方法
コンテナ名を付けるには--name
オプションを使用します。
docker run -p 80:80 --name mynginx -d nginx
この場合、-d
オプションでデタッチモードでnginx
を起動しています。
そのため、--name
オプションでmynginx
という名前を与えてます。
与えた名前を指定してログを出力することも可能です。
docker logs mynginx
実行ログ
コマンド
docker run -p 80:80 --name mynginx -d nginx
ログ確認コマンド
docker logs mynginx
実行
/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: 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 2023/06/04 02:58:15 [notice] 1#1: using the "epoll" event method 2023/06/04 02:58:15 [notice] 1#1: nginx/1.25.0 2023/06/04 02:58:15 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 2023/06/04 02:58:15 [notice] 1#1: OS: Linux 5.15.90.1-microsoft-standard-WSL2 2023/06/04 02:58:15 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2023/06/04 02:58:15 [notice] 1#1: start worker processes 2023/06/04 02:58:15 [notice] 1#1: start worker process 29 2023/06/04 02:58:15 [notice] 1#1: start worker process 30 2023/06/04 02:58:15 [notice] 1#1: start worker process 31 2023/06/04 02:58:15 [notice] 1#1: start worker process 32 2023/06/04 02:58:15 [notice] 1#1: start worker process 33 2023/06/04 02:58:15 [notice] 1#1: start worker process 34 2023/06/04 02:58:15 [notice] 1#1: start worker process 35 2023/06/04 02:58:15 [notice] 1#1: start worker process 36 2023/06/04 02:58:15 [notice] 1#1: start worker process 37 2023/06/04 02:58:15 [notice] 1#1: start worker process 38 2023/06/04 02:58:15 [notice] 1#1: start worker process 39 2023/06/04 02:58:15 [notice] 1#1: start worker process 40 2023/06/04 02:58:15 [notice] 1#1: start worker process 41 2023/06/04 02:58:15 [notice] 1#1: start worker process 42 2023/06/04 02:58:15 [notice] 1#1: start worker process 43 2023/06/04 02:58:15 [notice] 1#1: start worker process 44 2023/06/04 02:58:15 [notice] 1#1: start worker process 45 2023/06/04 02:58:15 [notice] 1#1: start worker process 46 2023/06/04 02:58:15 [notice] 1#1: start worker process 47 2023/06/04 02:58:15 [notice] 1#1: start worker process 48