I'm running this command in Docker docker run --restart always --network mysql_net --ip 192.169.0.2 --name mariadb -e MARIADB_ROOT_PASSWORD=example -v mariadb:/var/lib/mysql -d mariadb
But I'm getting this error : docker: Error response from daemon: network mysql_net not found.
I've been looking for info for a while now but due to I'm starting in Docker and i didn't find any info I can't find a solution.
It is because the network mysql_net does not exists yet. You can create e.g. bridge network as follows:
docker network create -d bridge mysql_net
But I recommend you starting it with docker-compose. See in official docker hub page of e.g. mariadb for docker-compose example.
Related
I'm trying to create a MYSQL docker container with volume using the following command:
docker run -d -v $(pwd)/api/db/data:/var/lib/mysql --rm --name mysql-container mysql-image
But i recieve the error:
Unable to find image 'de:latest' locally docker: Error response from
daemon: pull access denied for de, repository does not exist or may
require 'docker login': denied: requested access to the resource is
denied. See 'docker run --help'.
I'm alredy logged in my docker account and when i try creating the container without the volume, using this command:
docker run -d --rm --name mysql-container mysql-image
no errors occurs.
I have MYSQL container Running i am able to execute it and able to connect from host machine using "mysql -h 172.17.0.2 -u root -p". I have executed "docker run --name=mysql-host -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.32" to run the docker image.
but when i trying to access through Spring boot app it`s giving connection refused below are the properties in the application.properties
spring.datasource.url=jdbc:mysql://172.17.0.2:3306/auditLog?createDatabaseIfNotExist=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
i am runnung my jar as given below
java -jar service-1.0.0.jar spring.config.location=file:///home/10662598/Downloads/entity-search-service-deploymentFolder/entity-search-service/configs/application.properties
Error getting Caused by: java.net.ConnectException: Connection refused (Connection refused)
Your issue is probably because the Spring boot app can't reach the database (mysql), the reason for this is probably because they're not in same network.
If your Spring boot app is running inside container
From your question, I see that you're running containers using docker run..., therefore when you start MySQL and Spring boot app using that command, they're not in same network.
Solution for this is, first create a network, then start MySQL and Spring app to run within that network:
docker network create my-net
Then start your containers as usual but remember to add your containers to the network you just created:
docker run ... --network my-net
Now your containers are in same network and should reach each other, you can verify this by exec to Spring boot app and try curl to Mysql container using its container name (and port):
curl <mysql_container_name>:3306
If Spring boot app is running on host machine
Then simply make sure you map Mysql port to host machine and connect using localhost:<mapped_port>
Good luck :)
Here, you must create a network layer between the containers.
First create network layer
docker network create spring-mysql-net
Build & Run MySql Docker image
docker run --name mysql -d -e MYSQL_ROOT_PASSWORD=root -v
mysql:/var/lib/mysql --network spring-mysql-net mysql:8
Build your spring boot or any API
docker build -t restapi .
Start container on that created the network
docker container run --network spring-mysql-net --name
mysql-restapi-container -p 8080:8080 -d restapi
a bit late but i think you need to forward port 3306 on local machine to the contain port 3306
try this
docker run --name=mysql-host -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.32
I am using the docker images supplied at https://hub.docker.com/_/redmine
I have chosen to use MySQL as my database backend. So I have 2 docker containers: MySQL and Redmine, as downloaded from dockerhub.
Following the instructions on the docker/redmine link above, I ran through the commands and found that the redmine docker would not start. Inspecting the docker logs, I see:
rake aborted!
Mysql2::Error::ConnectionError: Unknown MySQL server host redmine (-5)
I thought the 2 dockers were having difficulty talking to each other, so I setup a new docker network for both containers to use:
docker network create --driver bridge redmine-net
Adapting the instructions, on the docker/redmine link above, I run
docker run -d name our-mysql --network redmine-net -e MYSQL_USER=redmine -e MYSQL_PASSWORD=todays-password -e MYSQL_DATABASE=redmine -e MYSQL_RANDOM_ROOT_PASSWORD=1 -p 3306:3306 mysql:5.7
docker run -d name our-redmine --network redmine-net -e REDMINE_DB_MYSQL=redmine -e REDMINE_DB_USERNAME=redmine -e REDMINE_DB_PASSWORD=todays-password redmine:latest
However, the redmine contain still falls over instantly, with the same error.
EDIT Using the *.yml file as provided in the dockerhub redmine instructions works pretty faultlessly.
So the question is: what is the docker-compose method doing that docker run isn't handling?
Thank you.
The REDMINE_DB_MYSQL arg of the redmine container do reference to the mysql container, so, if you define the database service like our-mysql, then set REDMINE_DB_MYSQL=our-mysql
I'm trying to create a simple mysql container, but I'm getting an error.
I created a Dockerfile:
FROM mysql
ENV MYSQL_ROOT_PASSWORD <password>
I built the image:
docker build -t mysql-image -f api/db/Dockerfile .
But when I tried to create a container with a host volume, an error appears:
docker run -d -v $(pwd)/api/db/data:/var/lib/mysql --rm --name mysql-container mysql-image
docker: Error response from daemon: pull access denied for de, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
If I run the same command, but without the volume parameters, then the container is created without any errors:
docker run -d --rm --name mysql-container mysql-image
I appreciate any help
Do you have whitespace in your current path? If so, it may be confusing the $(pwd) as two or more separate parameters. Try wrapping the whole parameter to -v in double quotes.
docker run -d -v "$(pwd)/api/db/data:/var/lib/mysql" --rm --name mysql-container mysql-image
I am still a beginner with docker, trying to use docker to help in my development prototyping. My environment is Mac using boot2docker, version as below
Client version: 1.3.1
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa
OS/Arch (client): darwin/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa
I ran the command as below:
docker run --name mymysql -e MYSQL_ROOT_PASSWORD=mypw -e MYSQL_DATABASE=bullshit -d mysql -p 3306:3306
docker start mymysql
I can see the process running as below:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
22d3f780c270 mysql:5 "/entrypoint.sh -p 3 2 minutes ago Up 2 seconds 3306/tcp mymysql
However I still could not connect to the mysql instance running in the docker. I tried connect to the ip retrieved by :
$ boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103
Please give me a pointer on how to solve this issue, I went through the tutorial but I am not sure what went wrong.
The command you used should give an error. The syntax for docker run is as follow:
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
You have to submit the options to docker run before specifying the image used (mysql in your case), and if it's the case, the command and possible argument(s) to that command.
Not specifying a command will run the default command in the image.
Before running again the container you should stop and remove the old one:
docker kill mymysql
docker rm mymysql
And, following your example you should run:
docker run --name mymysql -e MYSQL_ROOT_PASSWORD=mypw -e MYSQL_DATABASE=bullshit -p 3306:3306 -d mysql
As you set manually a port mapping from container's port 3306 to the same port of your Boot2docker VM, you should can access to MySQL using the IP of the Boot2docker instance, typically 192.168.59.103, and connecting to port 3306.