Initializing database in the base image of a running container

114 Views Asked by At

I pulled a mysql:5.5 image from the docker repo which I am using as a base image for my containerized app. After running this application that uses the mysql from the base image, it gives the following error

error: database is uninitialized and MYSQL_ROOT_PASSWORD not set Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?

How can I make sure that mysql is running on "localhost:3306" on the application container and that it is correctly initialized?

EDIT: Dockerfile

FROM mysql+java+ubuntu_baseimage:latest

# Copy the fat jar inside the image
COPY shaded_jar      /some/location/on/image/app.jar
COPY config.yml      /some/location/on/image/config.yml

 ## What to run when the container starts
#ENTRYPOINT ["java", "-jar", "/some/location/on/image/app.jar", "server",    "/some/location/on/image/config.yml"]

 #Ports used by this image
 EXPOSE 8080 (http port of the app)

Note that the container exposes both 8080 and 3306(mysql) port. But not sure how to connect to this database using 'ocalhost:3306" in the same container?

0

There are 0 best solutions below