Run docker oreilly http application from docker
docker run -p 4567:4567 -d rickfast/hello-oreilly-http
Run a docker container in foreground (it will exit when you hit CTRL+C)
docker run -p 4567:4567 rickfast/hello-oreilly-http
Stop a running container
docker stop {container-id}
Start a stoped container
docker start {container-name or id}
Restart a container
docker restart {container-name or id}
To list down docker runing containers
docker ps
To list down all docker container including stoped once
docker ps -a
Run docker container with a custom name
docker run --name rail-server -p 4567:4567 -d rickfast/hello-oreilly-http
Run a docker container and execute a command in it.
docker run ubuntu pwd
Run a docker container and ssh into container as the main command
docker run -it ubuntu /bin/bash
SSH to a running container
docker exec -it {container-name} /bin/bash
Run radis container with auto generated PORT number
docker run -d -P --name redis redis
Check the port number of container that running at
docker port {container name or id}
Run a container with custom environment variable
docker run -e "HELLO=WORLD" -e "MY_NAME=GAYAN" ubuntu /bin/bash -c export
Get the IP of running container
docker inspect --format='{{.NetworkSettings.IPAddress}}' {container name or id}
Run an application with some environment vairable
docker run -d -e "REDIS_PORT_6379_TCP_ADDR=172.17.0.2" --name web -p 4567:4567 rickfast/oreilly-simple-web-app
See logs of running container
docker logs -f {container id or name}