Question:
I follow some guides to install the wordpress + mysql by docker, but found that not work... I tried to test by curl command, found no any output, I need your help for the issue...
(I just transfer my wordpress hosting to VPS)
docker run --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql
docker run --name wordpress --link mysql:mysql -e WORDPRESS_DB_PASSWORD=123456 -d wordpress:4.8.2-apache
[root#vps ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6bd3954390e0 wordpress:4.8.2-apache "docker-entrypoint..." 11 seconds ago Up 10 seconds 80/tcp wordpress
eaa1f6a2fb96 mysql "docker-entrypoint..." 25 seconds ago Up 24 seconds 3306/tcp mysql
Follow troubleshooting and test wordpress:
[root#vps ~]# curl localhost:80
curl: (7) Failed connect to localhost:80; Connection refused
[root#vps ~]# docker inspect --format='{{.NetworkSettings.IPAddress}}' 6bd3954390e0
172.17.0.3
[root#vps ~]# curl 172.17.0.3:80
[root#vps ~]#
Resolved:
Thanks #junius(who in docker forums), #VladoDemcak, #yamenk and #user4860092! The issue was resolved!
If I do “docker run xxxx” that should not work for me, that maybe was caused by command incorrect. Then I tried to do docker-compose, curl no any output, but Wordpress should work normal. So curl no any output should normal.
Now, I completed task that transfer my Wordpress to new VPS, share follow tips and experiences:
Suggest follow docker official guide if you want to install WP by docker.
If you want to mapping the mysql and wordpress, can add follow
config in compose:
If you not config port part in compose, that mean not expose any
port to outside of container, so you couldn't access the port from
outside, as follow:
When you change “docker-compose.yml”, please not only use
“docker-compose down” that will not delete all config/file, suggest
you do “docker-compose down --volumes” that as install guide.
If you change database name, please add “WORDPRESS_DB_NAME: xxx” in
environment part of Wordpress(docker-compose.yml), that should no
this config in official install guide. So wordpress default connect
database name is “wordpress”.
If you want to debug wordpress/mysql and check log, you can not add
“-d”, use this “docker-compose up”
In order to restore mysql database, you can install phpmyadmin by
docker, then add follow config to “docker-compose.yml”, and follow
guide by “https://hub.docker.com/r/phpmyadmin/phpmyadmin/”
If you want to add some software in docker of Wordpress, e.g: zip,
mailx, you can do follow:
You don't have exposed ports, so you are not able to access wordpress (from host) which is running on the port 80 in docker container.
Probably you will need to expose port to some other port (not 80). So try to change docker run command for wordpress as follows:
docker run --name wordpress --link mysql:mysql -e WORDPRESS_DB_PASSWORD=123456 -p 81:80 -d wordpress:4.8.2-apache
Please notice -p 81:80 parameter in the command - Docker documentation expose-incoming-ports.
After that wordpress should be available on localhost:81.
I would suggest you to create docker-compose for your services rather than maintain linking and with docker-compose you are also able to run both services with one command.
There is a very detailed explanation in the official docker docs to how to do this. Follow the link below, and you shall get wordpress up and running.
https://docs.docker.com/compose/wordpress/
Related
My provider has "extended" my Plesk with MariaDB. Unfortunately, some things don't work anymore, so I'm looking for a way to install MySQL. That is why I'm looking for a way to install MySQL via Docker.
docker run -p 33060:3306 --name mysql-docker-eMYSQL_ROOT_PASSWORD=XXXX -d mysql
The MySQL server also seems to work - but only locally. But I can't connect from outside. I also tried to disable the firewall, temporarily. It wont work..
Can someone please help me to correctly install a MySQL server with Docker and how I can connect to the database?
Check your docker command carefully, you don't have space before and after -e. The command must be
run -p 33060:3306 --name mysql-docker -e MYSQL_ROOT_PASSWORD=XXXX -d mysql
I checked it worked for me
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
HI I have my web app running on my local machine and connected to Mysql workbench, I am now trying to dockerize the webapp. I can't seem to get it to connect to the DB on my local dev machine (I am running Docker Desktop for Windows), can anyone tell me how I would go about this? Here is what I have so far.
`docker run -it -e "CATALINA_OPTS=-Dspring.profiles.active=dev -DPARAM1=DEV" -p 8080:8080 -p 8005:8005 -p 8009:8009 -p 3306:3306 --add-host=docker:192.168.1.7 -v C:\myapp\trunk\target\myapp.war:/usr/local/tomcat/webapps/myapp.war --name waitapp tomcat:8.0.38-jre8`
after a few second, I run docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a1764dd9640 tomcat:8.0.38-jre8 "catalina.sh run" 2 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp, 0.0.0.0:8005->8005/tcp, 0.0.0.0:8009->8009/tcp, 0.0.0.0:8080->8080/tcp waitapp
The container seems to be running, but I get a 404 Not found when I try the rest request, this is the same as I do when running from inside spring tool suite using built in tomcat server.
NOTE
I don't want to run a separate mysql container and link the two over a network, I just want to try get my newly created docker app to connect to my local DB MySQL.
As mentioned on this post, you can try 2 things:
Add gateway and use it from containers, like
docker network create -d bridge --subnet 192.168.0.0/24 --gateway 192.168.0.1 dockernet
In addition to your app container, run proxy (ngnix?) container, which will rout the calls to DB when required
This answer also show how can you obtain the host IP inside the docker container.
I am new to Docker but i have read quite about it. Now my requirement is:
I will give my client a shell script which he would run on a base ubuntu os on a completely new system. The docker image should use the database of host system. The shell script will do all the prerequisites of installing docker, mysql, etc. and will run a docker image. As the image is not available locally, it will pull from docker repository.
Now my problem is that i dont want to give my client the sql dump file just like that. The dump is included in the image and once the images is run i want the image to connect to the host database and dump the data and then host the webapp.
My docker file is :
FROM ubuntu:14.04
MAINTAINER test_manoj
RUN pip install requirements.txt
ADD . /home/myapp/
RUN sudo apt-get install -y supervisor
WORKDIR /home/myapp/
EXPOSE 8000
EXPOSE 80
cmd ["supervisord", "-c", "/home/myapp/supervisord.conf"]
There are some more apt-get install-s but i didnt find it useful to mention here. So basically i am installing nginx, uwsgi, supervisor.
I have exposed port 8000 for socket uwsgi connections and port 80 for nginx.
My docker run command is :
docker run --detach --net=host -v /var/run/mysqld.sock:/var/run/mysqld/mysqld.sock manoj/mydocker
I am using -v to connect the host mysql to container's mysql.
I have already found a work around for my problem that is running
docker run --rm --detach --net=host -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock manoj/mydocker mysq -uroot -proot db_name < dump.sql
before the main run command. I know this works but is there any other way to do this? And is there any other way i can use host's mysql without providing -v tag?
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.