Database Image

MySQL image

1
// Example creation of MySQL DB running on Docker
2
docker pull mysql:8.0.25
3
docker run --name local_service_dashboard -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin1234 -d mysql:8.0.25
4
​
5
// Example MySQL Workbench setup:
6
Connection Name: local_service_dashboard
7
Hostname: 127.0.0.1
8
Port: 3306
9
Username: root
Copied!

Mongo DB with network option

1
// Get the mongo from docker hub
2
docker pull mongo
3
​
4
// Start the image in detached mode
5
docker run -d --name mongodb mongo
6
​
7
// Get info about the container in a dictionary form - you can get IP address for example
8
docker container inspect mongodb
9
​
10
// Create container network (IP are automatically resolved)
11
docker run --network my_network ...
12
​
13
// Stop container
14
docker stop mongodb
15
​
16
// Remove all stopped containers
17
docker container prune
18
​
19
// Create a docker network
20
docker network create network-name
21
​
22
// Inspect all existing networks
23
docker network ls
24
​
25
// Run the container with network option
26
docker run -d --name mongodb --network network-name mongo
27
​
28
//Requests to local machine use: host.docker.internal
Copied!