piszczynski>Aleks No edit summary |
piszczynski>Aleks |
||
Line 1: | Line 1: | ||
== Setup Docker == | == Setup Docker == | ||
[https://www.howtoforge.com/tutorial/ubuntu-docker-traefik-proxy/ Guide For setting up Traefik] | |||
Install latest docker-ce: | |||
*sudo apt install docker-ce | |||
Start the docker service and enable it to launch everytime at system boot. | |||
*systemctl start docker | |||
*systemctl enable docker | |||
Check version of docker: | |||
*docker version | |||
Additional: Running Docker for non-root user | |||
Docker container can be run under the non-root user. We just need to add the user to the docker group. | |||
Add 'aleks' user. | |||
*useradd -m -s /bin/bash aleks | |||
Now add the 'aleks' user to the docker group, then restart the docker service. | |||
*usermod -a -G docker aleks | |||
*systemctl restart docker | |||
Test by running the docker hello-world. | |||
*docker run -it hello-world | |||
Install Docker Compose | |||
*sudo apt install docker-compose | |||
Check version: | |||
*docker-compose version | |||
Create Custom Docker Network | |||
Check the available docker network on the system. | |||
*docker network ls | |||
== Docker Commands == | == Docker Commands == |
Revision as of 20:11, 20 August 2023
Setup Docker
Guide For setting up Traefik Install latest docker-ce:
- sudo apt install docker-ce
Start the docker service and enable it to launch everytime at system boot.
- systemctl start docker
- systemctl enable docker
Check version of docker:
- docker version
Additional: Running Docker for non-root user Docker container can be run under the non-root user. We just need to add the user to the docker group.
Add 'aleks' user.
- useradd -m -s /bin/bash aleks
Now add the 'aleks' user to the docker group, then restart the docker service.
- usermod -a -G docker aleks
- systemctl restart docker
Test by running the docker hello-world.
- docker run -it hello-world
Install Docker Compose
- sudo apt install docker-compose
Check version:
- docker-compose version
Create Custom Docker Network
Check the available docker network on the system.
- docker network ls
Docker Commands
Docker commands reference can be found here: https://docs.docker.com/engine/reference/run/
Stop docker container
- docker stop <container name>
remove container
- docker rm <container name>
run container
- docker run --name <container name>
When running docker containers the run command will require extra options for containers with specific uses. Environment vairables can be added to a document container on startup using a .env file and the switch "--env-file=<path to env file>" in the run command
Docker High CPU usage
See what containers are using system resources:
- docker stats --all
- docker stats --all --format "table Template:.ID\tTemplate:.Name\tTemplate:.CPUPerc\tTemplate:.MemUsage"
Check specific container for process:
- docker ps | grep <container id>
Check the logs for high cpu use container:
- docker logs --tail 100 <container Id>
Follow live logs:
- docker logs --follow <container ID>
restart docker container
- docker restart <container name>