docker命令启动
# 启动数据库容器db
docker run -d -v odoo-db:/var/lib/postgresql/data -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:15
# 启动Odoo容器,并与前面所建的db容器相连
docker run -v odoo-data:/var/lib/odoo -d -p 8069:8069 --name odoo --link db:db -t odoo
# 停止和启动指定容器
docker stop odoo
docker start -a odoo
Docker Compose 启动
vim docker-compose.yml
version: '3.1'
services:
odoo17web:
image: odoo:17.0
network_mode: host
volumes:
- ./odoo17data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
environment:
- HOST=172.16.160.18
- PORT=5432
- USER=postgres
- PASSWORD=postgres
- DB_NAME=odoo17
command: odoo -i base --without-demo=all
restart: always # 自动重启配置
docker compose up -d
其他 docker-compose.yml
文件示例:
version: '3.1'
services:
web:
image: odoo:17.0
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
environment:
- HOST=db
- USER=odoo
# - PASSWORD=myodoo
- PASSWORD_FILE=/run/secrets/postgresql_password
secrets:
- postgresql_password
db:
image: postgres:15
environment:
- POSTGRES_DB=postgres
# - POSTGRES_PASSWORD=myodoo
- POSTGRES_PASSWORD_FILE=/run/secrets/postgresql_password
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
secrets:
- postgresql_password
volumes:
odoo-web-data:
odoo-db-data:
secrets:
postgresql_password:
file: odoo_pg_pass
- secrets 配置项:密码文件挂载到容器内的具体位置,是由
secrets
配置项中的target
属性决定的。默认是挂载到/run/secrets/<secret_name>
路径。
https://hub.docker.com/_/odoo