CLI
Commands
run a command in a new container
docker run
- spec: Each time we execute
docker run, the Dockerfile is read. This is why callingdocker runon an existing container wouldn't make any sense.
show all running containers in docker engine
docker ps
- pass
-ato see all containers docker-compose pswill list containers in the docker engine that are related to the images specified indocker-compose.yml(thereforedc psis a subset ofdocker ps)
Start a container
docker container run --publish 8000:8080 --detach --name bb <APP NAME>
--publishasks Docker to forward traffic incoming on the host’s port 8000, to the container’s port 8080- containers have their own set of ports
- notice, we didn’t specify what process we wanted our container to run. We didn’t have to, since we used the CMD directive when building our Dockerfile; thanks to this, Docker knows to automatically run the process npm start inside our container when it starts up
- visit application at localhost:8000
Show all containers
docker container ls
Filter containers by those created by mongo image
docker container ls -f ancestor=mongo