docker:name_a_container
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
docker:name_a_container [2020/04/15 21:42] – peter | docker:name_a_container [2020/05/13 08:41] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Docker - Name a container ====== | ||
- | |||
- | By adding **< | ||
- | |||
- | There are limitations, | ||
- | |||
- | On the Command Line or in a Dockerfile: | ||
- | |||
- | <code bash> | ||
- | docker run --name=meaningful_name | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | 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 | ||
- | </ | ||
- | |||
- | The name would appear in the list of running containers: | ||
- | |||
- | <code bash> | ||
- | docker ps | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | CONTAINER ID IMAGE | ||
- | 08f333ef7216 | ||
- | </ | ||
- | |||
- | 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.1586986952.txt.gz · Last modified: 2020/07/15 09:30 (external edit)