Skip to content

Instantly share code, notes, and snippets.

@dbafromthecold
Last active February 7, 2020 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbafromthecold/021aa381bd6dafe38028e3bcfda231ef to your computer and use it in GitHub Desktop.
Save dbafromthecold/021aa381bd6dafe38028e3bcfda231ef to your computer and use it in GitHub Desktop.
Run mysql in a docker container
docker container run `
-d ` # detach the container (run it in the background)
--name arkkkd ` # give the container a name (arkkkd)
-p 3306:3306 ` # set port mapping from your computer to the container (3306 to 3306)
# setting environment variables for mysql
--env MYSQL_ALLOW_EMPTY_PASSWORD=True `
--env MYSQL_DATABASE=arkkk `
--env MYSQL_USER=root `
# set the image to run the container from
mysql:8
@kingbayo223
Copy link

This is clear. Thank you very much. I really do appreciate. I understand that an image was created and container generated. What I'm not clear about is where my database comes in the code. I.e my local database. I assume this is where its been set in docker ..

setting environment variables for mysql

--env MYSQL_ALLOW_EMPTY_PASSWORD=True --env MYSQL_DATABASE=arkkk
--env MYSQL_USER=root
Where arkkk is my database

If my assumption is true the I will like to know where the connection takes place with the image built for my springboot application.
I know how to create my dockfile in the application and I know how to generate my jar file already. All I want to know is the link that works btwn application and the local mysql db I.e arkkk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment