Odoo Docker镜像脚手架搭建:V10版本如何复现scaffold命令?
Hey there! Let's break down exactly how to run that odoo-bin scaffold openacademy addons command using the Odoo 10 Docker image, and make sure your scaffold files stick around after working with containers.
Prerequisites
First, make sure you've pulled the Odoo 10 Docker image if you haven't already:
docker pull odoo:10
Step 1: Prepare a Local Addons Directory
Docker containers are ephemeral by default—any files created inside them vanish when the container is deleted. To keep your scaffold module permanently, create a local directory on your host machine and set the right permissions (Odoo runs as user odoo with UID 1000 inside the container):
mkdir -p ./local-addons && chown -R 1000:1000 ./local-addons
Step 2: Run the Scaffold Command (Two Options)
You have two straightforward ways to execute the scaffold command:
Option 1: Use a Temporary Container (Clean & Quick)
This runs the command in a one-off container and deletes it right after, leaving your module in the local directory:
docker run --rm -v ./local-addons:/mnt/extra-addons odoo:10 odoo-bin scaffold openacademy /mnt/extra-addons
--rm: Automatically removes the container once the command finishes-v ./local-addons:/mnt/extra-addons: Mounts your local directory to the container's/mnt/extra-addonspath (a common spot for custom addons)- The final part is the actual scaffold command, pointing to the mounted directory so files save locally
Option 2: Enter a Running Container (For Ongoing Work)
If you already have an Odoo 10 container running (or want to keep one active), do this:
- Start a container with your local addons mounted (if you haven't already):
docker run -d -v ./local-addons:/mnt/extra-addons --name my-odoo10 odoo:10 - Enter the container's shell:
docker exec -it my-odoo10 bash - Run the scaffold command inside the container, targeting the mounted directory:
odoo-bin scaffold openacademy /mnt/extra-addons
Verify Your Module
Check your local ./local-addons directory—you should see the openacademy scaffold module with all the standard Odoo module files (models, views, controllers, etc.)!
内容的提问来源于stack exchange,提问作者Billal BEGUERADJ

