Docker-compose vs manual command line executions

hi guys, so I am trying to deploy the following image osticket/osticket - Docker Image | Docker Hub

In the quick start guide, they have this command line docker run commands for both mysql and the application osticket.

Quick Start

Ensure you have a MySQL container running that osTicket can use to store its data.

docker run --name osticket_mysql -d -e MYSQL_ROOT_PASSWORD=secret \
 -e MYSQL_USER=osticket -e MYSQL_PASSWORD=secret -e MYSQL_DATABASE=osticket mariadb

Now run this image and link the MySQL container.

docker run --name osticket -d --link osticket_mysql:mysql -p 8080:80 osticket/osticket

When I execute these two commands exactly as shown above, the website works via http://localhost:8080/scp/

Now, I tried to put the same into a docker-compose.yaml file:

version: '3.8'
services:
  osticket:
    container_name: osticket-web
    image: osticket/osticket
    environment:
      MYSQL_HOST: localhost
      MYSQL_PASSWORD: secret
    depends_on:
      - db
    ports:
      - 8080:80
  db:
    container_name: osticket-db
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: osticket
      MYSQL_USER: osticket
      MYSQL_PASSWORD: secret

when I look at the status, the osticket-web exits

NAME COMMAND SERVICE STATUS PORTS
osticket-db “docker-entrypoint.s…” db running 3306/tcp, 33060/tcp
osticket-web “entrypoint” osticket exited (1)

Looking at the logs it says:

Can anyone please help with the docker-compose version does NOT work but executing the 2 docker run commands work. I’m confused.

Thanks in advanced.

The docker run command for osticket differs from the compose file. MYSQL_HOST must be the service name of the db container and not localhost.

Localhost in a container is local to the container and not the same localhost as for another container or localhost for the host.

Also: you manged to put the docker run commands in a code block, but not the compose file or the log output. I wrapped the compose file content in a preformatted text block (</> icon) and the log ouput in a blockquote (" icon). Please wrap your content in such blocks were suited, as it becomes cumbersome to read it without,

1 Like

Thank you meyay,
I have lots to learn here.
So I went ahead and replaced localhost to db in MYSQL_HOST variable but still getting an error:

Install/Update osTicket
Configuring mail settings
OSTicket cron job is set to run every 5 minutes
Using external MySQL connection
Waiting for database TCP connection to become available…
Connecting to database mysql://osticket@db/osticket
************** INSTALLER FATAL ERROR ***************Unable to connect to MySQL server: The server requested authentication method unknown to the client
****************************************************Die :(%

I went ahead and deployed the 2 containers manually and had a look at the docker logs of the osticket container and see the following:

Install/Update osTicket
Configuring mail settings
OSTicket cron job is set to run every 5 minutes
Using linked MySQL container
Waiting for database TCP connection to become available…
Connecting to database mysql://osticket@mysql/osticket
Loading installation secret
Updating configuration file
Installing database. Please wait…
Database installation successful
Setting system language to en-us
Install Script finished!
Applying configuration file security
Removing setup files

I’m still not clear why this works but the docker-compose file doesn’t

Please share your current commands and the current compose file again. Lets see if they are identical this time.

Note: Each docker run argument can be translated into a compose file configuration. Both are just clients that parse either arguments or a configuration file, prepare a request with those details (which will look identical if configured identically) and send it to the docker engine that creates and starts the container(s).

1 Like

hello meyay,

thank you again for reaching out. I though I had replied earlier but it seems that is incorrect. In the docker-compose file, I changed the db image from mysql to mariadb and now everything is working as expected.

Thank you for all your contributions, it is much appreciated.

Oh, I didn’t notice that the docker run command used the mariadb image, and the compose file used the mysql image.

Glad, that it’s working now!

The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file. The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple

The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file. The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple

is that my answer is useful or not ?

I’m amazed because I just copy and paste the two commands from the “Quick Start” on my Mac Book but I can’t reach the application http://localhost:8080/scp/ as the documentation says !

Any help would be appreciated!
Thx