Prepare the images.
- Option1: pull the images from my Docker Hub
- Option2: build the images
docker pull ethankohl/breakfast-shop-apiserver
docker pull ethankohl/breakfast-shop-nextNOTE: Modify the images in docker-compose.yml accordingly.
# build the apiserver image
cd apiserver/
./mvnw clean package # might need to change the jar file name in Dockerfile accordingly
docker build -t apiserver:latest .
# build the next image
cd ../next/
docker build -t next:latest .- Put the init.sql in right place to setup mysql.
sudo mv init.sql /home/user/db/mysql/init/init.sql- Fill the environment variables in the env_files in env directory.
- Run.
docker-comopse upPort occupied
# install net-tools for netstat.
sudo apt-get update -y
sudo apt-get install -y net-tools
sudo netstat -lpn |grep 3000
sudo kill PIDCreate a database in a mysql container:
after publish a port from mysql container
mysql -P 3306 --protocol=tcp -u root -pStart mysql server
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql restartHow can I initialize a MySQL database with schema in a Docker container?
volumes:
- /home/user/db/mysql/data:/var/lib/mysql
- /home/user/db/mysql/init:/docker-entrypoint-initdb.d/:roAnd in the /home/user/db/mysql/init folder .. drop one sql file, with any name, for example init.sql containing something like :
CREATE DATABASE mydb;
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'%' IDENTIFIED BY 'mysql';
USE mydbHow can I grep for a string that begins with a dash/hyphen?
grep -- -XNextjs - importing next/document outside of pages/_document error
Component definition is missing display name react/display-name
