How to access the running wordpress container in the browser

Was trying to access a running WordPress container on the browser, so can someone assist me how to check the ports through which I need access the container in the browser, Thanks in advance.

Hi :slight_smile:

How do you start the container? Please provide the full command, or if you use compose, the compose file :slight_smile:

And you can see running containers with their port settings with: docker ps

Hi @terpz
Thanks for the response and please find the details below,
docker run -d --name test-wordpress -p 1143:8080 --link test-mysql:mysql --env=“MYSQL_ROOT_PASSWORD=XXXXX” wordpress
This is the way am linking the containers and trying to access
Am able to see the running containers but when am trying to access the wordpress container in the browser its giving issue.

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0278ce007ef0 wordpress “docker-entrypoint.s…” 4 days ago Up 3 seconds 80/tcp, 0.0.0.0:1143->8080/tcp test-wordpress
3869bbea8c7d mysql “docker-entrypoint.s…” 4 days ago Up 15 seconds 33060/tcp, 0.0.0.0:6603->3306/tcp test-mysql

Can you please assist me to resolve this issue and thanks in advance.

Hi again.

I see some issues, that im going to try and explain.
1: -p 1143:8080, means that you want to be able to visit (in this case) http://YOURSERVERIP:1143, which then goes to port 8080 in the container, that itself is fine, but according to the wordpress image, its not listning on port 8080, but instead 80.
so try and change it to -p 1143:80

2: Another “problem”, is that you use " –env=“MYSQL_ROOT_PASSWORD=XXXXX”" in the wordpress image, which it dosnt use, instead it uses:

WORDPRESS_DB_HOST, WORDPRESS_DB_USER, WORDPRESS_DB_PASSWORD, WORDPRESS_DB_NAME

What i would do, to make this more simple, is to install docker-compose, which gives you the possibility, to use a recipe for your application.
So, if you install docker-compose, and put this:

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'

into a file called: wordpress.yml
Then you can run this command, and it will take care of the rest:

docker-compose -f wordpress.yml up -d

Then you can visit your new wordpress installation, here: http://YOURSERVERIP:8080

( you might need to change the passwords, but that example should work so you can test it out )
( YOURSERVERIP can be localhost, if you run docker on your own pc )

Sure, thankq for the support and will try modifying the changes as per the suggestion. Will update the status. thanks once again for taking time for explaining/solving the issue.