Example | Description |
---|---|
docker ps | List running containers |
docker ps -a | List all containers |
docker ps -s | List running containers(with CPU / memory) |
docker images | List all images |
docker exec -it <container> bash | Connecting to container |
docker logs <container> | Shows container's console log |
docker stop <container> | Stop a container |
docker restart <container> | Restart a container |
docker rm <container> | Remove a container |
docker port <container> | Shows container's port mapping |
docker top <container> | List processes |
docker kill <container> | Kill a container |
Parameter <container> can be container id or name |
Getting Started
Create and run a container in background
$ docker run -d -p 80:80 docker/getting-started
-d
- Run the container in detached mode-p 80:80
- Map port 80 to port 80 in the containerdocker/getting-started
- The image to use Create and run a container in foreground
$ docker run -it -p 8001:8080 --name my-nginx nginx
-it
- Interactive bash mode-p 8001:8080
- Map port 8001 to port 8080 in the container--name my-nginx
- Specify a namenginx
- The image to use
Comments