Usage
Module:
Categories:
Pigsty includes built-in Docker support, allowing you to quickly deploy containerized applications.
Getting Started
Docker is an optional module and is not enabled by default in most Pigsty configuration templates. Users must explicitly download and configure Docker to use it within Pigsty.
For instance, in the default meta
template, Docker is not installed. However, the rich
single-node template will download and install Docker.
The key differences between these configurations are the repo_modules
and repo_packages
parameters:
repo_modules: infra,node,pgsql,docker # <--- Enable Docker repo
repo_packages:
- node-bootstrap, infra-package, infra-addons, node-package1, node-package2, pgsql-common, docker # <--- Download Docker
After downloading Docker, enable it on target nodes using the **docker_enabled**
: true
setting, and configure other parameters as needed:
infra:
hosts:
10.10.10.10: { infra_seq: 1, nodename: infra-1 }
10.10.10.11: { infra_seq: 2, nodename: infra-2 }
vars:
docker_enabled: true # Install Docker on this group
Finally, use the docker.yml
playbook to install:
./docker.yml -l infra # Install Docker on the infra group
Installation
To temporarily install Docker directly from the internet on selected nodes:
./node.yml -e '{"node_repo_modules":"node,docker","node_packages":["docker-ce,docker-compose-plugin"]}' -t node_repo,node_pkg -l <select_group_ip>
This enables the required repos (node,docker
) and installs packages docker-ce
and docker-compose-plugin
.
For automatic Docker downloads during Pigsty initialization, see below.
Uninstallation
Pigsty does not provide a dedicated Docker uninstall playbook due to simplicity. Uninstall Docker with Ansible directly:
ansible minio -m package -b -a 'name=docker-ce state=absent'
Download
To download Docker during Pigsty installation, enable Docker repositories by modifying repo_modules
and specifying Docker packages in repo_packages
or repo_extra_packages
:
repo_modules: infra,node,pgsql,docker # Enable Docker repo
repo_packages:
- node-bootstrap, infra-package, infra-addons, node-package1, node-package2, pgsql-common, docker
repo_extra_packages:
- pgsql-main docker
Packages defined here (docker-ce
, docker-compose-plugin
) are automatically downloaded during the default install.yml
run, becoming available via local repositories.
After Pigsty installation, update repositories by running ./infra.yml -t repo_build
.
Docker installation requires enabling the Docker module in repo_modules
.
Repository
Docker requires external repositories, pre-configured under repo_upstream
with the module name docker
:
- { name: docker-ce, description: 'Docker CE', module: docker, releases: [7,8,9], arch: [x86_64, aarch64], baseurl: { default: 'https://download.docker.com/linux/centos/$releasever/$basearch/stable', china: 'https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable', europe: 'https://mirrors.xtom.de/docker-ce/linux/centos/$releasever/$basearch/stable' }}
- { name: docker-ce, description: 'Docker CE', module: docker, releases: [11,12,20,22,24], arch: [x86_64, aarch64], baseurl: { default: 'https://download.docker.com/linux/${distro_name} ${distro_codename} stable', china: 'https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/${distro_name} ${distro_codename} stable' }}
Note: The official Docker repo is blocked by default in Mainland China. Use regional mirrors to resolve this.
Proxy
Configure network proxies using the proxy_env
parameter in Pigsty:
proxy_env:
no_proxy: "localhost,127.0.0.1,10.0.0.0/8,192.168.0.0/16,*.pigsty,*.aliyun.com,mirrors.*"
http_proxy: 'http://127.0.0.1:12345'
https_proxy: 'http://127.0.0.1:12345'
all_proxy: 'http://127.0.0.1:12345'
Use curl
to verify proxy effectiveness. Avoid combining proxy servers with Mainland China mirrors.
Mirror Sites
Specify Docker Registry Mirrors using docker_registry_mirrors
:
Example mirrors:
-
Alibaba Cloud:
["https://registry.cn-hangzhou.aliyuncs.com"]
-
Tencent Cloud:
["https://ccr.ccs.tencentyun.com"]
Pulling Images
Preload Docker images using docker_image
and docker_image_cache
:
infra:
hosts:
10.10.10.10: { infra_seq: 1 }
vars:
docker_enabled: true
docker_image:
- redis:latest
Or preload using local compressed images (tgz
files):
- name: copy local docker images
copy: src="{{ item }}" dest="/tmp/docker/"
with_fileglob: "/tmp/supabase/*.tgz"
Applications
Pigsty provides ready-to-use software templates based on Docker Compose to deploy external applications seamlessly integrated with Pigsty-managed database clusters.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.