- Developer machine → Docker Desktop or Docker Engine Community
- Small server → Docker Engine Community
- Critical applications → Docker Engine Enterprise or Kubernetes
- Container: a virtual machine
- Server: runs multiple Containers
- Image: a template used to create Container(s)
- Registry: storage for Images
docker run --help
docker ps -a
: lists all containersdocker ps
: lists the containers that are still running.docker image ls
: lists all imagesdocker logs [container ID]
: retrieves the logs of a container, even when it has stoppeddocker inspect [container ID]
: gets detailed information about a running or stopped containerdocker stop
: stops a container that is still runningdocker rm
: deletes a containerdocker image rm
: remove image
docker run hello-world
Pull down images and start services:
docker compose up
Install laravel dependencies:
docker compose run --rm composer install
Stopping the local service
docker compose stop
docker compose run --rm composer install
docker compose run --rm composer outdated
docker compose run --rm composer update
docker compose run --rm php php artisan
docker compose run --rm php php artisan test
Running all tests:
docker compose run --rm php php artisan test
Running a test suite:
docker compose run --rm php php artisan test --testsuite Feature
--rm
Removes the container after run-d
Detach, get the console back after run--build
Forces a rebuild of images
- docker app
- docker attach
- docker build
- docker builder
- docker buildx
- docker checkpoint
- docker commit
- docker compose
- docker config
- docker container
- docker context
- docker cp
- docker create
- docker diff
- docker events
- docker exec
- docker export
- docker history
- docker image
- docker images
- docker import
- docker info
- docker inspect
- docker kill
- docker load
- docker login
- docker logout
- docker logs
- docker manifest
- docker network
- docker node
- docker pause
- docker plugin
- docker port
- docker ps
- docker pull
- docker push
- docker rename
- docker restart
- docker rm
- docker rmi
- docker run
- docker save
- docker search
- docker secret
- docker service
- docker stack
- docker start
- docker stats
- docker stop
- docker swarm
- docker system
- docker tag
- docker top
- docker trust
- docker unpause
- docker update
- docker version
- docker volume
- docker wait
https://docs.docker.com/engine/reference/builder/
- FROM
- RUN
- RUN echo 'we are running some # of cool things'
- CMD
- LABEL
- EXPOSE
- ENV
- ADD
- COPY
- ENTRYPOINT
- VOLUME
- USER
- WORKDIR
- ARG
- ONBUILD
- STOPSIGNAL
- HEALTHCHECK
- SHELL
ENTRYPOINT + CMD = default container command arguments
- Vagrant creates and configures lightweight, reproducible, and portable development environments.
- Docker is an open platform for building, shipping, and running distributed applications.
Where Docker relies on the host operating system, Vagrant includes the operating system within itself as part of the package. One big difference between Docker and Vagrant is that Docker containers run on Linux, but Vagrant files can contain any operating system. That said, Docker does work with non-Linux operating systems. It just needs to run within a Linux virtual machine.
Docker is a containerization platform, and Kubernetes is a container orchestrator for container platforms like Docker.
Kubernetes, Mesos, and Docker Swarm are some of the more popular options for providing an abstraction to make a cluster of machines behave like one big machine, which is vital in a large-scale environment.
- https://www.virtualbox.org/wiki/Downloads
- https://minikube.sigs.k8s.io/docs/start/ –
brew install minikube
- https://docs.docker.com/docker-for-mac/install/
- https://docs.tilt.dev/install.html
local DNS resolver
192.168.1.247
sudo nano /etc/resolver/minikube-dev
Running:
minikube start
tilt up
~/postgres-docker/docker-compose.yml
:
version: '3'
services:
db:
image: postgres:15
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: [hidden]
POSTGRES_DB: admin_db # Just to ensure Postgres starts
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql # Define the real databases here
ports:
- "5432:5432"
volumes:
postgres-data:
~/postgres-docker/init.sql
:
-- CREATE USER "project_user" WITH ENCRYPTED PASSWORD '...'; GRANT ALL PRIVILEGES ON DATABASE "my-database" TO "project_user";
CREATE DATABASE "my-database"; GRANT ALL PRIVILEGES ON DATABASE "my-database" TO postgres;
Commands:
docker-compose down
docker-compose up -d
docker ps -a
docker logs postgres-docker-db-1
psql -h myserver.com -p 5432 -U postgres -W my-database