Manipulating containers
Last updated
Last updated
Since we ran our container in the background, how do we know if our container is running or what other containers are running on our machine? Well, we can run the docker ps
command. Just like on Linux to see a list of processes on your machine, we would run the ps
command. In the same spirit, we can run the docker ps
command which displays a list of containers running on our machine
Notice that the container we just restarted has been started in detached mode and has port 80 exposed. Also, observe the status of the container is Up X seconds
. When you restart a container, it starts with the same flags or commands that it was originally started with.
Standard practice is to name your containers for the simple reason that it is easier to identify what is running in the container and what application or service it is associated with.
To name a container, we just need to pass the --name
flag to the docker run
command.
That’s better! We can now easily identify our container based on the name we want and not any random name.