In one of the tutorials I found on Medium [cara-menginstall-odoo-menggunakan-docker]. There was a guide on Odoo with pgAdmin using Docker. Using pgAdmin makes it easier to monitor the state of PostgreSQL from outside the server. When I tried following this tutorial, it was quite easy; however, I encountered some difficulties with adding configurations. Therefore, in this tutorial, we will simplify that process, making it shorter and more straightforward
Step 1: Prerequisites Odoo with pgAdmin using Docker
Before we begin, ensure you have the knowlegde :
- Docker installed on your device. If not, follow the instructions here.
- Basic knowledge of Docker commands and Docker Compose.
- Access to a terminal or command prompt.
Step 2: Set Up Docker Compose for Odoo and PgAdmin
Next, we will set up Docker Compose to manage Odoo, PostgreSQL, and pgAdmin containers. Create a new directory for your project and within it, create a docker-compose.yml
Folder addons
and config
. Folder addons
for put your addons for odoo. In folder config
, create file odoo.conf
with content
[options]
addons_path = /mnt/extra-addons
admin_passwd = superadmin
csv_internal_sep = ,
data_dir = /var/lib/odoo/.local/share/Odoo
db_host = 172.18.0.1 # you can insert after docker compose
db_maxconn = 64
db_name = False
db_user = odoo
db_password = odoo
db_port = 5432
db_sslmode = prefer
db_template = template0
dbfilter = .*
demo = {}
email_from = False
from_filter = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 60
limit_time_real = 0
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = info
logfile =
longpolling_port = 8072
max_cron_threads = 2
osv_memory_age_limit = False
osv_memory_count_limit = False
pg_path =
pidfile =
proxy_mode = False
reportgz = False
screencasts =
screenshots = /tmp/odoo_tests
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_ssl_certificate_filename = False
smtp_ssl_private_key_filename = False
smtp_user = False
syslog = False
test_enable = False
test_file =
test_tags = None
transient_age_limit = 1.0
translate_modules = ['all']
unaccent = False
upgrade_path =
without_demo = False
workers = 0
file docker-compose.yml
with the following content:
networks:
odoo17-net:
name: odoo17-net
services:
db:
image: postgres:16
container_name: pgdb-1
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
volumes:
- local_pgdata:/var/lib/postgresql/data
networks:
- odoo17-net
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin4-1
restart: always
ports:
- '8080:80'
environment:
PGADMIN_DEFAULT_EMAIL: root@gmail.com
PGADMIN_DEFAULT_PASSWORD: password
volumes:
- pgadmin-data:/var/lib/pgadmin
networks:
- odoo17-net
odoo:
#image: odoodev:17.0
image: odoo:17
container_name: o17-1
ports:
- "8017:8069"
- "8888:8888"
# entrypoint: /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo -c /etc/odoo/odoo.conf
restart: "unless-stopped"
volumes:
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
- odoo-o17-data:/var/lib/odoo
networks:
- odoo17-net
volumes:
local_pgdata:
pgadmin-data:
odoo-o17-data:
This configuration includes three services: PostgreSQL, pgAdmin, and Odoo. Each service is connected to a Docker network named odoo17-net
to facilitate communication between the containers.
- PostgreSQL (db): The
postgres:16
image is used, with the database accessible on port 5432. Environment variables are set for the PostgreSQL user and password, and the database data is stored in thelocal_pgdata
volume. - pgAdmin (pgadmin): The
dpage/pgadmin4
image is used, with pgAdmin accessible on port 8080. Environment variables are set for the pgAdmin user email and password, and pgAdmin data is stored in thepgadmin-data
volume. - Odoo (odoo): The custom
odoodev:17.0
image is used, with Odoo accessible on port 8017 and the debug port on 8888. The entrypoint command starts Odoo with debugging enabled viadebugpy
. You can follow this tutorial. If you don’t need custom image you can set it default image fromOdoo
with tag17
orlatest
- in entrypoint if you use custom image you can set
entrypoint: /usr/bin/python3 -m debugpy --listen 0.0.0.0:8888 /usr/bin/odoo -c /etc/odoo/odoo.conf
for debug it in vscode. If you dont use custom image dont need set it - Odoo configuration files are stored in the
config
volume, extra add-ons are stored in theaddons
volume, and Odoo data is stored in theodoo-o17-data
volume.
To start these services, run the following command in your terminal:
docker-compose up -d
This command will build and run the containers in detached mode. You can check the status of the containers by running:
docker-compose ps
Step 3: Inspect Docker Network
After starting the containers, inspect the Docker network to get the gateway address, which you will use as the host in your configurations. Open a terminal and run:
docker network inspect odoo17-net
This command will display detailed information about the network, including the gateway address. Look for the Gateway
field in the output, which should look something like this:
[
{
"Name": "odoo17-net",
"Id": "abcdef123456",
"Created": "2024-06-15T12:34:56.789012345Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
...
}
]
Note the Gateway
address (172.18.0.1
in this example). Use this address in your Odoo configuration file.
Step 4: Initialize PostgreSQL Server with PgAdmin
Once the containers are up and running, you can check pgAdmin by navigating to http://localhost:8080
in your browser. Log in using the credentials specified in the pgAdmin environment settings.
- Email:
root@gmail.com
- Password:
password
After logging in, follow these steps to register a new PostgreSQL server:
- Right-click on “Servers” and select “Register” > “Server”.
- In the “General” tab, enter a name for your server. For example, you can name it “local” to indicate it’s your local PostgreSQL server.
Switch to the “Connection” tab and fill in the following details:
- Hostname: Enter the gateway address obtained earlier (
172.18.0.1
). - Port: Enter the PostgreSQL running port (
5432
). - Username: Enter the PostgreSQL username (
root
). - Password: Enter the PostgreSQL password (
password
).
- Click “Save” to register the server.
Once you register the server, create a new login/group role for Odoo. This is necessary because each Odoo container needs a unique login/group role.
- Right-click on the registered server and navigate to “Create” > “Login/Group Role”.
- Enter a name for the role. For example fill it with
odoo
. - In the “Definition” tab, set the password for the role (
odoo
). - In the “Privileges” tab, enable all privileges.
Click “Save” to create the new role. Your PostgreSQL setup is now complete, and your Odoo instance can use this role to connect to the database.
Step 5: Run Odoo
Next, run Odoo. You can access Odoo at localhost:8017
(according to the port specified in the Docker Compose file). Then, a screen for creating a new database will appear. Use the password superadmin
.
Once the database is created, you can log in with the username and password you entered on the previous screen.
Conclusion
By following this step-by-step guide, you will have successfully installed Odoo with PgAdmin using Docker. This setup ensures seamless integration and simplifies the deployment process, making it easier to manage your Odoo and PostgreSQL environments. If you have any questions or need further assistance, feel free to reach out. Happy coding!
Discover more from teguhteja.id
Subscribe to get the latest posts sent to your email.