Skip to content

Instantly share code, notes, and snippets.

@Btibert3
Last active September 19, 2021 23:40
Show Gist options
  • Save Btibert3/98cdb0ffe726322300a49c384fc6a2e9 to your computer and use it in GitHub Desktop.
Save Btibert3/98cdb0ffe726322300a49c384fc6a2e9 to your computer and use it in GitHub Desktop.
MySQL 5 docker-compose

Steps

  1. Open up the terminal
  2. Make sure you go to the home directory via: cd ~
  3. Create a new folder called sfdc via: mkdir sfdc
  4. Change into that directory via : cd sfdc
  5. Copy the contents of the file into docker-compose.yml into that directory. In the terminal, ls should print out docker-compose.yml
  6. Make sure the docker app is running on your machine
  7. In the terminal, run the command docker-compose up

Above, we could also use the command docker-compose up -d which runs the container detached, but above is good to help see if there are any issues

After a few minutes, connect to the MySQL database via your tool of choice (e.g. Dbeaver). You if you do not run the command with -d, the first time might take a few minutes as it pulls the necessary tooling down to your computer.

To stop the container, contrl + c if you followed step 7 below, and then docker-compose stop if you used docker-compose up -d. You will need to use docker-compose stop to properly stop the container. You can monitor if the container is running via Docker App (in the toolbar) and Dashboard.

version: '3.3'
services:
db:
image: mysql:5.7
platform: linux/x86_64
restart: always
environment:
MYSQL_DATABASE: 'db'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'user'
# You can use whatever password you like
MYSQL_PASSWORD: 'password'
# Password for root access
MYSQL_ROOT_PASSWORD: 'password'
ports:
# <Port exposed> : < MySQL Port running inside container>
- '3306:3306'
expose:
# Opens port 3306 on the container
- '3306'
# Where our data will be persisted
volumes:
- my-db:/var/lib/mysql
# Names our volume
volumes:
my-db:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment