- Run the following command to start an Ubuntu container
docker run ubuntu:latest echo "Welcome to Ubuntu"
- Run the following command to start an Ubuntu container with interactive bash shell
docker run --name samplecontainer -it ubuntu:latest /bin/bash
- Listing running containers
docker ps
- Listing all containers (runing/stopped)
docker ps -a
docker images
- Run an alpine container in the background
docker run --name pingcontainer -d alpine:latest ping 127.0.0.1 -c 50
- Looking at the logs (stdout) of a container
docker logs -f pingcontainer
docker run -d --name nginxalpine -p 7777:80 nginx:alpine
- Accessing the container service from the host system using mapped port
curl localhost:7777
- Accessing the container service using the container IP and container port
docker exec -it nginxalpine sh
ip addr
curl 172.17.0.2:80