I am new to Docker and tried to install WordPress in Docker
Details are :
OS : Windows 10 Home
Docker Version : Docker version 19.03.1, build 74b1e89e8a
docker-compose version 1.24.1, build 4667896b
I done following steps
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mysql
MYSQL_USER: admin
MYSQL_PASSWORD: admin
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: admin
WORDPRESS_DB_PASSWORD: admin
WORDPRESS_DB_NAME: admin
volume:
db_data: {}
It is working fine
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
944e0ea8ff69 wordpress:latest "docker-entrypoint.s…" 34 minutes ago Up 34 minutes 0.0.0.0:8000->80/tcp wordpress_wordpress_1
5a3890fed7fe redis "docker-entrypoint.s…" 45 minutes ago Up 45 minutes 6379/tcp sleepy_matsumoto
4edf3f9fc944 mysql:5.7 "docker-entrypoint.s…" About an hour ago Up 38 minutes 3306/tcp, 33060/tcp wordpress_db_1
But when I am running http://localhost:8000 or http://localhost:80 in browser it is showing site is not reachable. How can I resolve this?
I got an answer for this problem details are as under as I have installed docker using Docker Toolbox
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v19.03.5
Now if I do
http://192.168.99.100:8000/
Now finally it is working. Hopefully it will help you too
Related
I've run my docker-compose file trying to dockerize pgadmin for Postgres but my browser cannot connect to pgadmin on url localhost:8080.
This is the docker-compose file that I am running
version: '3'
services:
db:
container_name: postgres_container
image: postgres
restart: always
environment:
POSTGRES_DB: postgres_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: secret
PGDATA: /var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
- db-data:/var/lib/postgresql/data
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4:5.5
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: admin#admin.com
PGADMIN_DEFAULT_PASSWORD: secret
PGADMIN_LISTEN_PORT: 80
ports:
- "8080:80"
volumes:
- pgadmin-data:/var/lib/pgadmin
volumes:
db-data:
pgadmin-data:
This is my docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c6a6a588f639 dpage/pgadmin4:5.5 "/entrypoint.sh" 3 hours ago Up 9 minutes 443/tcp, 0.0.0.0:8080->80/tcp pgadmin4_container
ad6fe3349717 postgres "docker-entrypoint.s" 3 hours ago Up 9 minutes 0.0.0.0:5432->5432/tcp postgres_container
When I try to connect to it from browser to localhost:8080 it says Connection attempt failed
I am using almost the same docker compose file on Windows 10 with WSL 2 and can connect immediately using Firefox build 100 browser to localhost:8080.
My difference is that the image for pgadmin4 in the compose file is image: dpage/pgadmin4
the latest not v5.5
I solved this problem. Turns out that DOCKER_HOST variable was set to 192.168.99.100:2376. You can see it by running command echo $DOCKER_HOST
I just ran my docker container into this port instead of localhost and everything worked fine.
docker run -d -p 192.168.99.100:9411:9411 openzipkin/zipkin
And I was able to access my docker container through the browser by url http://192.168.99.100:9411/ Thank you very much everyone
I'm using docker with docker-compose.yml file.
There I put two different services inside, which I'd like to update.
Moreover I ran portainer and added also some other services there:
pi#raspberrypi:~/docker $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ec830e789d38 nodered/node-red:latest "npm --no-update-not…" 8 days ago Up 6 minutes (healthy) 0.0.0.0:1880->1880/tcp, :::1880->1880/tcp docker_node-red_1
15aa942b2b94 openhab/openhab:3.1.1 "/entrypoint gosu op…" 8 days ago Up 8 days (healthy) docker_openhab_1
e805e3f527c4 portainer/portainer-ce "/portainer" 8 days ago Up 8 days 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp portainer
80990d1ad7e7 influxdb:latest "/entrypoint.sh infl…" 9 months ago Up 8 days InfluxDB
My actual docker-compose.yml file looks like this:
pi#raspberrypi:~/docker $ cat docker-compose.yml
version: "2"
services:
openhab:
image: "openhab/openhab:3.1.1"
restart: always
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "./openhab_addons:/openhab/addons"
- "./openhab_conf:/openhab/conf"
- "./openhab_userdata:/openhab/userdata"
environment:
USER_ID: "1000"
GROUP_ID: "1000"
OPENHAB_HTTP_PORT: "8080"
OPENHAB_HTTPS_PORT: "8443"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
services:
node-red:
image: nodered/node-red:latest
environment:
- TZ=Europe/Amsterdam
ports:
- "1880:1880"
networks:
- node-red-net
volumes:
- node-red-data:/data
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
volumes:
node-red-data:
networks:
node-red-net:
In order to update the openhab container from 3.1.1 to 3.2.0, I changed the image name inside compose file to openhab/openhab:3.2.0.
Afterwards I started docker-compose pull and the system only checked if there is a new image for node-red available. But not for openhab.
What is wrong?
You need to put all the services under a single services key. That's also why it's plural.
services:
openhab:
...
node-red:
...
I am having an application service and a MySQL service but I am not able to connect the two containers and it keeps returning me this error
jango.db.utils.OperationalError: (2002, "Can't connect to MySQL server on '127.0.0.1' (115)")
I have included the links in my application service but nothing is working out.
Mine MySQL container is working up fine and even I can log into the MySQL container.
Here is the snapshot of the services:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cc26d09a81d1 gmasmatrix_worker:latest "/entrypoint.sh /sta…" 17 seconds ago Exited (1) 11 seconds ago gmasmatrix_celeryworker_1
749f23c37b16 gmasmatrix_application:latest "/entrypoint.sh /sta…" 18 seconds ago Exited (1) 9 seconds ago gmasmatrix_application_1
666029ad063a gmasmatrix_flower "/entrypoint.sh /sta…" 18 seconds ago Exited (1) 10 seconds ago gmasmatrix_flower_1
50ac0497e66b mysql:5.7.10 "/entrypoint.sh mysq…" 21 seconds ago Up 17 seconds 0.0.0.0:3306->3306/tcp gmasmatrix_db_1
669fbbe0a81d mailhog/mailhog:v1.0.0 "MailHog" 21 seconds ago Up 18 seconds 1025/tcp, 0.0.0.0:8025->8025/tcp gmasmatrix_mailhog_1
235a46c8d453 redis:5.0 "docker-entrypoint.s…" 21 seconds ago Up 17 seconds 6379/tcp gmasmatrix_redis_1
Docker-compose file
version: '2'
services:
application: &application
image: gmasmatrix_application:latest
command: /start.sh
volumes:
- .:/app
# env_file:
# - .env
ports:
- 8000:8000
# cpu_shares: 874
# mem_limit: 1610612736
# mem_reservation: 1610612736
build:
context: ./
dockerfile: ./compose/local/application/Dockerfile
args:
- GMAS_ENV_TYPE=local
links:
- "db"
celeryworker:
<<: *application
image: gmasmatrix_worker:latest
depends_on:
- redis
- mailhog
ports: []
command: /start-celeryworker
links:
- "db"
flower:
<<: *application
image: gmasmatrix_flower
ports:
- "5555:5555"
command: /start-flower
links:
- "db"
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "8025:8025"
redis:
image: redis:5.0
db:
image: mysql:5.7.10
environment:
MYSQL_DATABASE: gmas_mkt
MYSQL_ROOT_PASSWORD: pulkit1607
ports:
- "3306:3306"
``
Your application is trying to connect to 127.0.0.1 - which in docker points to the app container itself.
Instead you should use the IP of the db container. You can utilize the built-in docker DNS service to do this. In your application configuration, use db (the name of the mysql container) as the host to connect to instead of localhost or 127.0.0.1
I am getting an "Internal Server Error" when trying to install Odoo 12 Community Edition on an AWS EC2 instance using a docker-compose file. My EC2 instance uses Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1031-aws x86_64) operating system, Docker version 18.09.0 and docker-compose version 1.23.2.
Here is my docker-compose.yml file:
version: '2'
services:
web:
image: odoo:12.0
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./config:/etc/odoo
- ./addons:/mnt/extra-addons
db:
image: postgres:10
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
volumes:
odoo-web-data:
odoo-db-data:
I can see the containers being created as is evidenced by the following output of the "docker ps -a" command:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64e271db9565 odoo:12.0 "/entrypoint.sh odoo" 2 hours ago Up 2 hours 0.0.0.0:8069->8069/tcp, 8071/tcp ubuntu_web_1
10b3198e3230 postgres:10 "docker-entrypoint.s…" 2 hours ago Up 2 hours 5432/tcp ubuntu_db_1
Moreover, the "docker-compose config" command returned the following output:
services:
db:
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_PASSWORD: odoo
POSTGRES_USER: odoo
image: postgres:10
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata:rw
web:
depends_on:
- db
image: odoo:12.0
ports:
- 8069:8069/tcp
volumes:
- odoo-web-data:/var/lib/odoo:rw
- /home/ubuntu/config:/etc/odoo:rw
- /home/ubuntu/addons:/mnt/extra-addons:rw
version: '2.0'
volumes:
odoo-db-data: {}
odoo-web-data: {}
What am I missing here?
I'm getting the below error message when doing a docker-compose up:
ERROR: repository phusionphp not found: does not exist or no pull access
However I have built this image with docker build -t phusionphp:7.0 .
I am able to run this directly using sudo docker run -it --rm phusionphp:7.0:
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 9
Jun 16 12:00:57 a62ea0266f66 syslog-ng[15]: syslog-ng starting up; version='3.5.6'
ls
^C*** Shutting down runit daemon (PID 9)...
*** Killing all processes...
docker-compose.yaml:
version: '3.1'
services:
php:
image: phusionphp:7
ports:
- 3306:3306
volumes:
- ./data/mariadb:/var/lib/mysql
links:
- mysql
apache:
image: phusionapache
ports:
- 3306:3306
links:
- php
mysql:
image: mysql:5.7
ports:
- 3306:3306
volumes:
- ./data/mariadb:/var/lib/mysql
environment:
MYSQL_USER: "example"
MYSQL_PASSWORD: "example"
MYSQL_ROOT_PASSWORD: "example"
MYSQL_DATABASE: "example"
Seems I have the images present, sudo docker images:
customlamp/phusionphp latest 65221e392f1f 17 minutes ago 317MB
phusionphp 7.0 65221e392f1f 17 minutes ago 317MB
phusionphp 5.6 488fda307f61 27 minutes ago 317MB
phusionphp latest 488fda307f61 27 minutes ago 317MB
customlamp/phusionphp 5.6 488fda307f61 27 minutes ago 317MB
What am I missing here?
You have image phusionphp:7.0
So reference it with the whole tag 7.0 or without the tag to use latest.
Don't reference it just with 7 as tag.
So image: phusionphp:7.0
or image: phusionphp
instead of
image: phusionphp:7