π A platform to develop, ship, and run applications in containers, making them portable and consistent across environments.
π Containers: Running instances of Docker images. Think of them as lightweight, isolated environments.
π Dockerfile: A script with instructions to build Docker images (e.g., from Ubuntu, install packages, copy code, etc.).
π Docker Compose: A tool to define and manage multi-container apps using docker-compose.yml.
π Networking: Docker provides isolated virtual networks; containers can communicate using service names.
β Common Docker Commands
# Run a container
docker run -d -p 8080:80 nginx
# Build image from Dockerfile
docker build -t myapp .
# List running containers
docker ps
# Start/stop containers
docker start <id> && docker stop <id>
# Remove container/image
docker rm <id> && docker rmi <image>
- Install Server - I am using Hyper-V and Ubuntu Server LTS
- Install updates
- Install Docker and set running docker without sudo (avoiding using sudo with every docker command)
sudo usermod -aG docker $USER
The docker group is created automatically during the Docker installation. - Install Docker Compose sudo apt install -y docker-compose
- mkdir nextcloud-docker
- cd nextcloud-docker
- Create a docker-compose.yml file:
version: '3'
services:
db:
image: mariadb:10.6
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_PASSWORD=nextcloudpass
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextclouduser
app:
image: nextcloud
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
restart: always
environment:
- MYSQL_PASSWORD=nextcloudpass
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextclouduser
- MYSQL_HOST=db
volumes:
db:
nextcloud:
- docker-compose up -d
- http://your-server-ip:8080
