How to install ERPNext through Docker on WSL?

I’m running Ubuntu-22.04 LTS on WSL Windows 11 10.0.22000.

I’ve tried a lot of guides and youtube videos but got stuck in one step or the other when trying the manual installation method.

The easy install script is not working. It throws an error saying platform.dist() is not supported. Line 100 of the script.

Can someone point me in the right direction? I don’t want to run it on a live server but on my local machine.

If you’re using docker, there’s no need for easy install scripts. I’ve set up a few machines for docker via wsl, and though I don’t remember the exact process I didn’t encounter any significant hurdles. The guide on the official docker repo has always worked for me:

2 Likes

@harshit54 Follow the guide frappe_docker on github religiously as @peterg shared.
It is very well written.

On windows, make sure you have WSL 2 and latest Docker Desktop installed. Good (almost to extent of required) to have VSCode.
(Based on your comment, I guess this is already taken care in your system. But for everyone’s sake…). Further to run Docker with WSL, you need to have VM (or similar) setting enabled in bios while your processor should support.

2 Likes

After a long time of trying and failing, I managed to make it run, but unfortunately, only work with development.
Once I switched to the production and accessed it through port 80, the site seems like crashed or no CSS has been loaded. And I’m still struggling and trying to fix it with no luck whatsoever.
However, you can follow these steps which will make your container up and running on dev (port 8000):

Before I begin, I’m following the instruction on this link to make it running on Ubuntu 22.04:

First of all, I used MariaDB official image from Docker Hub:

docker run -d -p 80:80 -p 8000:8000 -e MYSQL_ROOT_PASSWORD=password mariadb:10.8.3

This will start a container in the background, and to login to it, use the following command:

docker exec -t <container id> bash

Please replace <container id> with your container id which can be found by executing the command: docker container ls.

Once you have logged in to your container, begin installing the following requirements:

apt update -y
apt install software-properties-common -y
apt install sudo nano -y

Then start creating a frappe user and set the password for it frappe as well:

adduser frappe

“I didn’t try to change the user or its password yet, so I can’t guarantee it will work if you did.”

Then start assigning this user with sudo group:

usermod -aG sudo frappe

Then

su frappe
cd ~

once you get there, we will continue installing the rest of the requirements:

sudo apt install git python3-dev python3-setuptools python3-pip virtualenv redis-server curl npm xvfb libfontconfig wkhtmltopdf cron nginx supervisor libmysqlclient-dev libmariadb-dev -y

After completing the installation, enter the following command:

mysql_secure_installation

(Please note the default password is ( password ) as we have set it on the first docker command).

Then enter ( y ) to every question and change the mariadb root password to whatever you want.
Then edit mariadb configuration file by executing the following command:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Then replace the content of the file with the following:

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see

# this is read by the standalone daemon and embedded servers
[server]
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 0.0.0.0
query_cache_size = 16M
log_error = /var/log/mysql/error.log
# this is only for the mysqld standalone daemon
[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
#
# * Basic Settings
#

#user                    = mysql
pid-file                = /run/mysqld/mysqld.pid
basedir                 = /usr
#datadir                 = /var/lib/mysql
#tmpdir                  = /tmp

# Broken reverse DNS slows down connections considerably and name resolve is
# safe to skip if there are no "host by domain name" access grants
#skip-name-resolve

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address            = 127.0.0.1

#
# * Fine Tuning
#

#key_buffer_size        = 128M
#max_allowed_packet     = 1G
#thread_stack           = 192K
#thread_cache_size      = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
#myisam_recover_options = BACKUP
#max_connections        = 100
#table_cache            = 64

#
# * Logging and Replication
#

# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# Recommend only changing this at runtime for short testing periods if needed!
#general_log_file       = /var/log/mysql/mysql.log
#general_log            = 1

# When running under systemd, error logging goes via stdout/stderr to journald
# and when running legacy init error logging goes to syslog due to
# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf
# Enable this if you want to have error logging into a separate file
#log_error = /var/log/mysql/error.log
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file    = /var/log/mysql/mariadb-slow.log
#long_query_time        = 10
#log_slow_verbosity     = query_plan,explain
#log-queries-not-using-indexes
#min_examined_row_limit = 1000

# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
#max_binlog_size        = 100M

#
# * SSL/TLS
#

# For documentation, please read
# https://mariadb.com/kb/en/securing-connections-for-client-and-server/
#ssl-ca = /etc/mysql/cacert.pem
#ssl-cert = /etc/mysql/server-cert.pem
#ssl-key = /etc/mysql/server-key.pem
#require-secure-transport = on

#
# * Character sets
#

# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
#character-set-server  = utf8mb4
#collation-server      = utf8mb4_general_ci

#
# * InnoDB
#

# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# Most important is to give InnoDB 80 % of the system RAM for buffer use:
# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size
#innodb_buffer_pool_size = 8G

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.8 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.8]

[mysql]
default-character-set = utf8mb4

Then restart mariadb service by executing:

sudo service mariadb restart

Most likely your container will kick you out of the session now, just enter docker exec -it <container id> bash , and hit enter to get back to it, then repeat switch to frappe user again by using su frappe then change directory to frappe home by using cd ~.

Then execute the following command:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

Then:

source ~/.profile

Then:

nvm install 14.15.0 
sudo npm install -g yarn
sudo -H pip3 install frappe-bench

At this point, you are ready to initialize bench by using the following command:

bench init --version v13.32.0 frappe-bench

Please note that I specified the version to be v13.32.0 which I have already test it, I don’t know about other versions.

Then:

bench start

Then press on the keyboard Ctrl+C to kill the process.
Then create your first site by executing the following command:

bench new-site <site name>.localhost

The is your chosen site name (for example: site name ‘erp’ will be ‘erp.localhost’)
Please note that I added .localhost at the end of the site name as many people suggest using it specifically with docker containers! Therefore I didn’t try to remove it.

Then you need to generate supervisor & nginx configurations by executing the following command:

bench setup supervisor
bench setup nginx

Please hit ( y ) to rewrite the files (if prompt)

Then execute the following commands to start the services:

sudo service supervisor start
sudo service nginx start

Then run the bench by executing the following command:

bench start

You should now have access from the host device to http://``.localhost:8000

You can now add ERPnext to your frappe framework by executing the following:

bench get-app --branch v13.32.0 erpnext
bench --site `<site name>'.localhost install-app erpnext

I hope this answers your question, and I hope it works as expected.

3 Likes

@adelalmajed if your css is not loading, that means you are struggling with user permissions to nginx and supervisor.

your nginx ideally should have access to user’s frappe directory where the “static” resources are kept. So in nginx config file change the user, which ideally should be at the top on config file at /etc/nginx/nginx.conf.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.