docker run | Docker Docs

Github repos

learning-docker/1-getting-started-guide/ at main · spawnmarvel/learning-docker · GitHub

docker ps -a

docker images


docker search mariadb

docker pull mariadb:11

docker images

run mariadb with the image id

docker run –name mariadb1 -e MYSQL_ROOT_PASSWORD=mypass -p 3306:3306 -d c74611c2858a

create a new container from the same image (just for test, this is scaling)

docker run –name mariadb2 -e MYSQL_ROOT_PASSWORD=mypass -p 3307:3307 -d c74611c2858a

docker ps

docker ps -a

docker rm mariadb2 –force

connecting to mariadb from outside the container

docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ mariadb1

ip is returned

mysql -h -u root -p

Add sql and restart vm to view persistent data

docker stop mariadb1

docker start mariadb2

docker ps

enter the container again

restart the vm and do the same, and the data is still there.

make it always start, instead of starting it

docker update –restart always mariadb1

docker inspect mariadb1

enter the container, out with exit 13

docker exec -it mariadb1 bash

exit 13

docker logs mariadb1