instead of using docker ip address of container how can app use assigned IP address of AWS Lightsail

0

Hi, I have a static IP address assigned to AWS Lightsail instance. This IP Address was cleared for me to get access to MariaDB. I am now using docker for my project and docker has another IP address than that of the instance. This results in an error stating: "IPxxx" is not allowed to connect to this mariadb server. Is there anything I have to do within AWS to get this access? Thanks in advance.

  • Need clarification, please. Are you asking how to run a docker container so that it looks as if its network requests originate from the instance on which it runs?

  • @Pavel-AWS yeah that's exactly what I am looking for if it's possible, thanks

profile picture
asked 2 years ago760 views
2 Answers
1

From description in docker reference, you'll probably want to run on host network: --network host option. Please check out other network options in the reference, and see which likely applied to your use case. But to me it sounds like you need host.

With the network set to host a container will share the host’s network stack and all interfaces from the host will be available to the container.

AWS
MODERATOR
answered 2 years ago
  • Hey, I tried using network_mode: host in my docker-compose file. However, I get an error that: "host" network_mode is incompatible with port_bindings. Prior to host, I was using bridge network and basically the error that I get on AWS Lightsail "172.19.0.2' is not allowed to connect to this MariaDB server" where "172.19.0.2" is the app container IP address.

  • The port bindings settings are only available in certain networking modes. In "host" mode, since your services running inside the container are sharing the host's network stack, any service you start there will bind to the port on the host. This means that port bindings are essentially meaningless in this mode and should be removed from your docker file and/or startup parameters.

0

Is this an RDS MariaDB instance running inside AWS or is it RDS running on EC2 or is it RDS running on-prem?

When you say "This IP Address was cleared for me to get access to MariaDB" what exactly do you mean?

Also is the docker container running inside an EC2 or on an on-prem machine?

If everything is running inside AWS, you may want to check the security group around RDS MariaDB allows inbound traffic on the MariaDB port from the security group of the EC2 instance on which docker is running.

It will be more helpful if you can provide an architecture diagram?

profile pictureAWS
EXPERT
answered 2 years ago
  • Hi, MariaDB is running separately not in AWS. I am referring to the static IP address of my AWS Lightsail instance. I meant "whitelisted" so that I can only get access to MariaDB if I am requesting through this IP address. The docker container is running inside my AWS Lightsail instance. I do not have an architecture diagram really.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions