Connect to DynamoDB Local from inside docker container with boto3 Connect to DynamoDB Local from inside docker container with boto3 python-3.x python-3.x

Connect to DynamoDB Local from inside docker container with boto3


You are using the docker link feature to connect two containers together. The fundamental principles here are:

  1. You give your DB container a unique name, using --name.
  2. You link your client container to the DB, using --link specifying the name of your DB container and an alias for it inside the client container.
  3. Docker then connects the two using its default bridge network.

In doing so, it doesn't need a port mapping to the host network (as provided by the -p option). Instead docker will do the work for you and expose the IP addresses and ports as needed inside your client container, using the alias you defined when creating the link.

You can then use this alias to look up the details inside the client container using the environment variables docker automatically creates for you.

You've basically got it all right apart from this last step. If you check out your environment, I expect you'll find port 8000 is the one you want.