Search code examples
oracle-databasedockerdocker-machine

Localhost doesn't forward requests to Oracle Docker container


I'm trying to switch from Vagrant to Docker (too late to go back now).

I've deleted my Oracle Vbox already, and I have:

So I created the Docker container using this command :

docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c

Then I tried to setup users/permission etc using localhost:8080/em which was unreachable.

Then I opened Kinematic to see if I could find my container IP and I found there that my Docker container IP is 192.x.x.x

I was able to login into 192.x.x.x:8080/em and setup what I needed to setup.

And my app is connecting to the Docker when I specify the docker ip: 192.x.x.x

But it should be really connecting via localhost, why is the localhost:8080/em not working and why is the app not able to connect to Docker container via localhost?

It's working for all my other team-mates, I'm using mac OS Sierra.


Solution

  • Short answer:

    Despite what I said in my comment, it turns out you didn't wait long enough before trying to connect to the container. Display the logs to see when init is done, then try again.

    Long answer:

    I got it working this way. First, I started the container (I only added the --name for simplicity sake):

    $> docker run -d -p 8080:8080 -p 1521:1521 --name oracle-12c sath89/oracle-12c
    

    Then I tried to connect to the container, doing a simple:

    $> curl http://localhot:8080
    curl: (52) Empty reply from server
    

    That didn't work, so I displayed the container's logs:

    $> docker logs -f oracle-12c
    

    It showed me that the container needed time to start up, with the following logs:

    ls: cannot access /u01/app/oracle/oradata: No such file or directory
    Database not initialized. Initializing database.
    Starting tnslsnr
    Copying database files
    1% complete
    3% complete
    11% complete
    18% complete
    37% complete
    Creating and starting Oracle instance
    40% complete
    45% complete
    50% complete
    55% complete
    56% complete
    60% complete
    62% complete
    Completing Database Creation
    66% complete
    70% complete
    73% complete
    85% complete
    96% complete
    100% complete
    Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details.
    Configuring Apex console
    Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed
    Starting web management console
    
    PL/SQL procedure successfully completed.
    
    Starting import from '/docker-entrypoint-initdb.d':
    found file /docker-entrypoint-initdb.d//docker-entrypoint-initdb.d/*
    [IMPORT] /entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
    
    Import finished
    
    Database ready to use. Enjoy! ;)
    

    It took me about 15min to init the db. Then it was working