- Docker desktop Download link
- Docker ubuntu
Uninstall older versions
sudo apt-get remove docker docker-engine docker.io containerd runc
Install last version
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Create MySQL container and use with MySQL Workbench
If using docker desktop be sure you have it up and running
- First step is to look for the image in the Docker Hub
- Here we will be using the latest mysql image available we pull the image using the command
docker image pull
- After the download is completed we verify the image using the command
docker images
- To create and run the container of mysql we can use the command
docker container run
here we provide the container name, environment variables, define localhost port, to run in background mode and the image of mysql
- This will provide a container id and we can verify the container using the command
docker ps
. We see that container id correspond to the container small id and the port 3306 of our host is mapped to the port 3306 of the container
- Finally we can use MySQL Workbench to verify our container is up and running. We provide the hostname: localhost port: 3306 username: root and password: root .
4.- At end we can stop the container execution using the command docker container stop
, remove container using the command docker container rm
, and remove image of mysql using the command docker image rm
.
Create MySQL container and use with Adminer container
If using docker desktop be sure you have it up and running
- First step is to look for the image in the Docker Hub
- Here we will be using the latest mysql image available we pull the image using the command
docker image pull
- After the download is completed we verify the image using the command
docker images
- First step is to look for the image in the Docker Hub
- Here we will be using the latest adminer image available we pull the image using the command
docker image pull
- After the download is completed we verify the image using the command
docker images
-
To create and run the container of mysql we can use the command
docker run
here we provide the container name, environment variables, define localhost port, to run in background mode and the image of mysql -
This will provide a container id and we can verify the container using the command
docker ps
. We see that container id correspond to the container small id and the port 3306 of our host is mapped to the port 3306 of the container
-
To create and run the container of adminer we can use the command
docker run
here we provide the container name, link to another container, define localhost port, to run in background mode and the image of adminer -
This will provide a container id and we can verify the container using the command
docker ps
. We see that container id correspond to the container small id and the port 3306 of our host is mapped to the port 3306 of the container
We link the container of adminer to the container of mysql using the option --link. Now we can access to localhost:8080 and set params System: MySQL, Server: mysqlito, Username: userdb, password: passworddb, Database: mysqldb.Those where defined in mysql container creation.
-
Finally we can stop containers with command
docker stop
-
Remove containers with command
docker rm
-
Verify containers are removed with command
docker ps -a
-
Remove images with command
docker image rm
-
Verify images are removed with command
docker images
Now we are going to use docker-compose
This will help us to download images, create, (re)build, starts multi-containers all of that with a single file and command
If using docker desktop be sure you have it up and running
docker-compose.yml example file
docker-compose.yml file allows you to configure and document all your application's service dependencies (other services, cache, databases, queues, etc.). Using the docker-compose CLI command, you can create and start one or more containers for each dependency with a single command (docker-compose up).
What is defined in the file are this:
- version Specifies the version of the Docker Compose syntax to be used in the file.
- services Defines the individual services (containers) that make up the application. Each service is specified as a key-value pair, where the key is the name of the service and the value is a set of properties that configure the service. Properties can include the Docker image to be used, environment variables, ports to be exposed, volumes to be mounted, and other configurations.
- networks Defines the networks to be used by the services. Networks enable communication between different services within the same Docker Compose application.
- volumes Defines the volumes to be used by the services. Volumes are used to persist data across container restarts or to share data between containers.
- configs and secrets Define configurations and secrets to be used by the services. Configurations and secrets are used to externalize configuration data and sensitive information, respectively, from the docker-compose.yml file.
- deploy Specifies configurations related to deployment of the services in a swarm mode Docker cluster, such as replicas, placement constraints, and update policies.
- To pull required images we use command
docker-compose pull
this will pull images defined in docker-compose.yml
- We verify the images downloaded
docker image ls
- Now to run the containers defined in docker-compose we use the command
docker-compose up -d
this will create and start the containers.
- We can verify in localhost:8080 and set params System: MySQL, Server: mysqlito, Username: userdb, password: passworddb, Database: mysqldb.Those where defined in mysql container creation.
-
Finally we can stop containers with command
docker stop
-
Remove containers with command
docker rm
-
Verify containers are removed with command
docker ps -a
-
Remove images with command
docker image rm
-
Verify images are removed with command
docker images