User Tools

Site Tools


docker:name_a_container

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker:name_a_container [2017/02/22 16:29] peterdocker:name_a_container [2020/05/13 08:41] (current) – removed peter
Line 1: Line 1:
-====== Docker - Name a container ====== 
- 
-By adding **<nowiki>--name=meaningful_name</nowiki>** to the **docker run** command, the name becomes more recognizable in interactive sessions as well as in the output of commands like docker ps.  There are limitations, however since container names must be unique, you cannot use deliberate naming and scale a service beyond one container. 
- 
-On the Command Line or in a Dockerfile: 
- 
-<code bash> 
-docker run --name=meaningful_name 
-</code> 
- 
-For example, if we ran a container based on the nginx base image and started it like this: 
- 
-<code bash> 
-docker run --name nginx -d nginx 
-</code> 
- 
-The name would appear in the list of running containers: 
- 
-<code bash> 
-docker ps 
-</code> 
- 
-Output: 
- 
-<code> 
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES 
-08f333ef7216        nginx               "nginx -g 'daemon off"   15 seconds ago      Up 14 seconds       80/tcp, 443/tcp      nginx 
-</code> 
- 
-While the name appears in the output of docker ps and can be used to manage the container, it will not appear in the command prompt of the container if you attach to it or in log files.  In order to accomplish that, you'll also need to assign a hostname. 
  
docker/name_a_container.1487780963.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki