How to Name or Rename Docker Containers
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their software, libraries, and configuration files -- they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.
Prerequisites
It requires Docker installed and Docker Container running on the server.
For detailed installation, refer to Docker installation.
Naming a Docker Container
By default, a Docker container will have UUID as an identifier.
You can find out by running docker images on the command line to get this information.
You can give a unique name for each container by using the --name.
Note: You can Start and Stop the container using this unique name!!
docker run -d --name Custom_name_here centos
- You will have to provide a name for your docker container in place of
Custom_name_here. - In this example,
centosis a docker image that we had pulled before hand.
Output:
root@vps:~# docker run -d --name my_project centos
8280db405ef0d58f0e105d85697333ad1272bc67c5f00b8a7a33bc64a0db0c67
To run the Container you need to get the Container ID or Name -- enter the following command to get the required information.
docker ps -l
Output:
root@vps:~# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64dcb5a85587 centos "/bin/bash" 7 seconds ago Exited (0) 6 seconds ago my_project
Renaming a Docker Container
Run the following command to Rename the Docker Container.
docker rename my_project my_centos_project
- You will have to provide a New name for your docker container in place of
New-name.
Output:
docker rename my_project my_centos_project
To confirm the Docker Container New name.
docker ps -l
Output:
root@vps:~# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64dcb5a85587 centos "/bin/bash" 7 minutes ago Exited (0) 7 minutes ago my_centos_project CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS