Docker Basic Setup: Difference between revisions

From WikiMLT
m (Стадий: 3 [Фаза:Разработване, Статус:Разутвърден]; Категория:Linux Server)
Line 46: Line 46:
=== Prune All ===
=== Prune All ===
Simple script that will prune all Docker ''containers'' and ''images'' that are not in use. If you want to use it, add the script somewhere in your <code>$PATH</code> to be accessible as shell command and make it executable.
Simple script that will prune all Docker ''containers'' and ''images'' that are not in use. If you want to use it, add the script somewhere in your <code>$PATH</code> to be accessible as shell command and make it executable.
<syntaxhighlight lang="shell" class="mlw-continue">
<syntaxhighlight lang="shell" class="mlw-continue" line="1">
docker-prune.sh
sudo nano /usr/local/bin/docker-prune.sh && sudo chmod +x /usr/local/bin/docker-prune.sh
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang="bash" line="1">
<syntaxhighlight lang="bash" line="1">
#!/bin/bash
#!/bin/bash
docker image prune -a  
docker image prune -a
docker container prune
docker container prune
docker images prune
docker images prune

Revision as of 09:41, 25 September 2022

In­stall Dock­er

In­stall Dock­er on Ubun­tu and oth­er De­bian based dis­tros.

sudo apt install docker.io curl
sudo usermod -aG docker "$USER"

Ref­er­ences:

In­stall Dock­er Com­pose

More in­for­ma­tion at Get start­ed with Dock­er Com­pose.

# docker-compose from github.com/docker/compose#where-to-get-docker-compose
sudo curl -L --fail \
https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Al­ter­na­tive­ly, for ex­am­ple, one can use Dock­er-com­pose pro­vid­ed by Linuxserver​.io.

#CLI
# docker-compose from linuxserver.io
sudo curl -L --fail \
https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh \
-o /usr/local/bin/docker-compose && \
sudo chmod +x /usr/local/bin/docker-compose

Ba­sics Ex­am­ple

Here is a GitHub repos­i­to­ry that il­lus­trates at very ba­sic lev­el how to use Dock­er­file and docler-compose.yaml to de­ploy a Node.js ap­pli­ca­tion.

Mis­cel­la­neous

Prune All

Sim­ple script that will prune all Dock­er con­tain­ers and im­ages that are not in use. If you want to use it, add the script some­where in your $PATH to be ac­ces­si­ble as shell com­mand and make it ex­e­cutable.

sudo nano /usr/local/bin/docker-prune.sh && sudo chmod +x /usr/local/bin/docker-prune.sh
#!/bin/bash
docker image prune -a
docker container prune
docker images prune
docker system prune

Force up­date ex­ist­ing im­ages with dock­er-com­pose

docker-compose up --force-recreate --build -d
docker image prune -f

Log-in to a Dock­er Con­tain­er

docker exec -it container(id|name) /bin/bash

Gen­er­ate Hashed Pass­word for Code-serv­er

printf 'your-password' | npx argon2-cli -e | sed 's/\$/$$/g'

De­mo App from Nana's Dock­er Tu­to­r­i­al for Be­gin­ners