To list the running containers:
$ docker ps
To list all containers - stopped:
$ docker ps -a
To delete:
$ docker rm <container_id>
To use ephemeral docker:
$ docker run -rm ruby:3.2.2 ruby -e "puts :hello"
Build image:
$ docker build [options] path/to/build/directory
List images:
$ docker images
To publish port:
$ docker run -p port-out:port-in image_id command for example: $ docker run -p 3000:3000 image_id bin/rails s -b 0.0.0.0
Tagging images:
$ docker tag image_id <image_name>[:<tag>] during build: $ docker build -t railsapp -t railsapp:1.0 .
Clean imags
$ docker image prune
List currently defined networks
$ docker network ls
Start/build services
$ docker-compose up
Launch app in background
$ docker-compose up -d
Check list of running containers
$ docker-compose ps
Stop all containers:
$ docker-compose stop
Stop particular service:
$ docker-compose stop <service_name>
Restart service:
$ docker-compose restart <service_name>
Viewing the containers logs
$ docker-compose logs -f
Running off-off commands.
$ docker-compose run --rm service command
Running command using already working one.
$ docker-compose exec container_name command
Rebuild mage
$ docker-compose build service
Create machine
docker-machine create --driver virtualbox --virtualbox-memory "2048" --virtualbox-hostonly-cidr 192.168.56.1/21 local-vm-1
List machines
$ docker-machine ls
Ssh to machine
$ docker-machine ssh local-vm-1 or $ docker-machine ssh <instance name> "command"
To replay you need to login. Don't have an account? Sign up for one.