Skip to content

Instantly share code, notes, and snippets.

@khiemdoan
Last active December 31, 2024 13:03
Show Gist options
  • Select an option

  • Save khiemdoan/483e86b668c1f677aba2cc239546d06b to your computer and use it in GitHub Desktop.

Select an option

Save khiemdoan/483e86b668c1f677aba2cc239546d06b to your computer and use it in GitHub Desktop.
Container Setup

Docker

Container configs

Update /etc/docker/daemon.json file.

{
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

~/.docker/config.json

{
  "auths": ...,
  "status": "OK"
}

Auto clean system

# sudo crontab -e

@daily docker system prune --all --force
@reboot docker system prune --all --force

Check container disk usage

sudo du -h --max-depth=1 /var/lib/docker | sort -hr

Allow containers access public network

sudo ufw allow from 172.16.0.0/12

Restart all containers

docker restart $(docker ps -a -q)

Podman

Installation

# Debian / Ubuntu
sudo apt install podman podman-compose

# Fedora / AlmaLinux
sudo dnf install podman podman-compose

sudo loginctl enable-linger $UID
systemctl --user enable podman-restart

Update containers

systemctl --user start podman-auto-update

Auto clean system

# sudo crontab -e

@daily podman system prune --all --force
@reboot podman system prune --all --force

Credential file:

${XDG_RUNTIME_DIR}/containers/auth.json
# or
${XDG_CONFIG_HOME}/containers/auth.json (usually ~/.config/containers/auth.json)
$HOME/.docker/config.json
$HOME/.dockercfg

Container configs

/etc/containers/containers.conf
# $HOME/.config/containers/containers.conf

[containers]
log_size_max=10485760
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment