Hi @farleyknight, thx for the guide! I followed your steps but my instance is not starting. When I check the log I see pretty strange error that keeps showing up again and again:
Waiting for MySQL...
DNS fwd/rev mismatch: ec2-54-86-250-45.compute-1.amazonaws.com != ip-172-31-36-241.ec2.internal
no port[s] to connect to
Do you have any ideas why this can happen? If yes, can you please share how did you solve it? If not, maybe you can give me a hint how I can troubleshoot this issue?
@farleyknight
, the mysql connected and created/migrated db, however the web service is not starting, docker log from aws:
2021-01-30T13:32:00.100-08:00 yarn install v1.22.5
2021-01-30T13:32:00.201-08:00 [1/4] Resolving packages...
2021-01-30T13:32:00.204-08:00 success Already up-to-date.
2021-01-30T13:32:00.207-08:00 Done in 0.12s.
2021-01-30T13:32:01.318-08:00 DNS fwd/rev mismatch: ec2-54-86-250-45.compute-1.amazonaws.com != ip-172-31-36-241.ec2.internal
2021-01-30T13:32:01.319-08:00 ec2-54-86-250-45.compute-1.amazonaws.com [172.31.36.241] 3306 (mysql) open
2021-01-30T13:32:01.320-08:00 MySQL is up and running!
2021-01-30T13:32:05.197-08:00 Database 'the-greatest-rails-app-ever_test' already exists
2021-01-30T13:32:05.410-08:00 Created database 'the-greatest-rails-app-ever_development'
2021-01-30T13:32:05.410-08:00 == 20210129091928 CreateBlogPosts: migrating ==================================
2021-01-30T13:32:05.410-08:00 -- create_table(:blog_posts)
2021-01-30T13:32:05.410-08:00 -> 0.0259s
2021-01-30T13:32:05.410-08:00 == 20210129091928 CreateBlogPosts: migrated (0.0259s) =========================
2021-01-30T13:32:05.415-08:00 MySQL database has been created & migrated!
2021-01-30T13:32:05.415-08:00 test: 1
2021-01-30T13:32:05.420-08:00 test: 2
It seems like aws container for unknown reason is stuck executing this command:
bundle exec rails server -b 0.0.0.0 -p 8080
Do you have any idea why this can happen?
P.S. I added echo before bundle exec to make sure that container finished running previous lines:
# If the database exists, migrate. Otherwise setup (create and migrate)
bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:create db:migrate
echo "MySQL database has been created & migrated!"
echo 'test: 1'
# Remove a potentially pre-existing server.pid for Rails.
rm -f tmp/pids/server.pid
echo 'test: 2'
# Run the Rails server
bundle exec rails server -b 0.0.0.0 -p 8080
To anybody who is having the same problem as I had, it turns out that ruby on rails on docker container application in my case was running on random port (e.g. 32768, check screens below). This happened because in container settings the port was set to be 0, that means just to use random Host Port. Because of this, simple ping to 80 or 8080 port was not passing thru instance running container.
I figured that out by ssh-ing to instance that runs container (mentioned in this article above under Test the SSH connection section) and running docker ps command (see the screen below)
Simple check I used to see if the request is forwarded to container or not is to execute curl localhost:32768 from instance running container (see the screen below)
So to sum up, the app was working, but I was checking a wrong port (80 or 8080). What I should have done is just to open instance url:Host Port, where Host Port was randomly selected and it was not selected to be 80 or 8080.
To fix this issue you should modify container routing to explicitly set Host Port to be equal to 80 or 8080 (or any other port you choose to run web application)
Hi @farleyknight, thx for the guide! I followed your steps but my instance is not starting. When I check the log I see pretty strange error that keeps showing up again and again:
Do you have any ideas why this can happen? If yes, can you please share how did you solve it? If not, maybe you can give me a hint how I can troubleshoot this issue?
Thx a lot for this guide and your help!
@farleyknight , the mysql connected and created/migrated db, however the web service is not starting, docker log from aws:
It seems like aws container for unknown reason is stuck executing this command:
Do you have any idea why this can happen?
P.S. I added echo before
bundle execto make sure that container finished running previous lines:To anybody who is having the same problem as I had, it turns out that ruby on rails on docker container application in my case was running on random port (e.g. 32768, check screens below). This happened because in container settings the port was set to be 0, that means just to use random Host Port. Because of this, simple ping to 80 or 8080 port was not passing thru instance running container.
I figured that out by ssh-ing to instance that runs container (mentioned in this article above under Test the SSH connection section) and running
docker pscommand (see the screen below)Simple check I used to see if the request is forwarded to container or not is to execute
curl localhost:32768from instance running container (see the screen below)So to sum up, the app was working, but I was checking a wrong port (80 or 8080). What I should have done is just to open instance url:Host Port, where Host Port was randomly selected and it was not selected to be 80 or 8080.
To fix this issue you should modify container routing to explicitly set Host Port to be equal to 80 or 8080 (or any other port you choose to run web application)
How did you solved database connection issue?
@farleyknight I am also facing the similiar problem. Can you please help me with this?