Target commands
docker run
docker stop (container ID)
docker start (container ID)
docker logs (container ID)
docker rm -f (container ID)
Docker run
I will try running the NGINX image.
docker run -d -p 8080:80 nginx
I will check the running containers.
docker ps --format "CONTAINER ID: {{.ID}}\nIMAGE: {{.Image}}\nCOMMAND: {{.Command}}\nCREATED: {{.CreatedAt}}\nSTATUS: {{.Status}}\nPORTS: {{.Ports}}\nNAMES: {{.Names}}"
CONTAINER ID: 157a491d1dc8
IMAGE: nginx
COMMAND: "/docker-entrypoint.…"
CREATED: 2023-05-21 18:16:14 +0900 JST
STATUS: Up 14 minutes
PORTS: 0.0.0.0:8080->80/tcp
NAMES: vigorous_mclaren
Docker stop
docker stop 157a491d1dc8 (container id)
157a491d1dc8
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Docker start
If you want to start the same container again, you would execute the "start" command. Running the "run" command would create a new container.
docker start 157a491d1dc8 (container id)
157a491d1dc8
Docker logs
To check the logs, you can execute the following command
docker logs 157a491d1dc8
Docker rm
To remove a container, you can use the "rm" command. If you want to remove a running container, you need to include the "-f" option when executing the command.
docker rm -f 157a491d1dc8 or 157