Not able to access docker public port.

I am studying  Managing Applications and Infrastructure with Terraform course. I have setup terraform on Linux academy cloud server but when I am running docker on it, I am unable to access deployed container using public ports.  


terrform_package $terraform workspace show
prod
terrform_package $terraform plan
var.env
env: dev or prod
Enter a value: prod
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ module.container.docker_container.container_id
id: <computed>
attach: "false"
bridge: <computed>
container_logs: <computed>
exit_code: <computed>
gateway: <computed>
image: "${var.image}"
ip_address: <computed>
ip_prefix_length: <computed>
log_driver: "json-file"
logs: "false"
must_run: "true"
name: "prod_blog"
network_data.#: <computed>
ports.#: "1"
ports.0.external: "80"
ports.0.internal: "2386"
ports.0.ip: "0.0.0.0"
ports.0.protocol: "tcp"
restart: "no"
rm: "false"
start: "true"

+ module.image.docker_image.image_id
id: <computed>
latest: <computed>
name: "ghost:alpine"


Plan: 2 to add, 0 to change, 0 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

terrform_package $terraform apply
var.env
env: dev or prod

Enter a value: prod


An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

+ module.container.docker_container.container_id
id: <computed>
attach: "false"
bridge: <computed>
container_logs: <computed>
exit_code: <computed>
gateway: <computed>
image: "${var.image}"
ip_address: <computed>
ip_prefix_length: <computed>
log_driver: "json-file"
logs: "false"
must_run: "true"
name: "prod_blog"
network_data.#: <computed>
ports.#: "1"
ports.0.external: "80"
ports.0.internal: "2386"
ports.0.ip: "0.0.0.0"
ports.0.protocol: "tcp"
restart: "no"
rm: "false"
start: "true"
+ module.image.docker_image.image_id
id: <computed>
latest: <computed>
name: "ghost:alpine"
Plan: 2 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------




  • post-author-pic
    Kamlesh V
    12-13-2018

     "resources": {
    "docker_container.container_id": {
    "type": "docker_container",
    "depends_on": [],
    "primary": {
    "id": "2b7f1112ab879704b5f480cb34d520205aef3e4851be7efb4dfaf6dc315365af",
    "attributes": {
    "attach": "false",
    "bridge": "",
    "gateway": "172.17.0.1",
    "id": "2b7f1112ab879704b5f480cb34d520205aef3e4851be7efb4dfaf6dc315365af",
    "image": "sha256:3747c12ff84131b6015f61bee35731b67ad665c933551b6c88a402c172ff6cd3",
    "ip_address": "172.17.0.2",
    "ip_prefix_length": "16",
    "log_driver": "json-file",
    "logs": "false",
    "must_run": "true",
    "name": "prod_blog",
    "network_data.#": "1",
    "network_data.0.gateway": "172.17.0.1",
    "network_data.0.ip_address": "172.17.0.2",
    "network_data.0.ip_prefix_length": "16",
    "network_data.0.network_name": "bridge",
    "ports.#": "1",
    "ports.0.external": "80",
    "ports.0.internal": "2386",
    "ports.0.ip": "0.0.0.0",
    "ports.0.protocol": "tcp",
    "restart": "no",
    "rm": "false",
    "start": "true"


    Active Internet connections (only servers)

    Proto Recv-Q Send-Q Local Address Foreign Address State

    tcp 0 0 *:ssh *:* LISTEN

    tcp6 0 0 [::]:31297 [::]:* LISTEN

    tcp6 0 0 [::]:http [::]:* LISTEN

    tcp6 0 0 [::]:ssh [::]:* LISTEN

    prod $netstat

    Active Internet connections (w/o servers)

    Proto Recv-Q Send-Q Local Address Foreign Address State

    tcp 0 0 ip-172-31-16-36.a:50626 x.x.x.xhttps ESTABLISHED

    tcp6 0 0 ip-172-31-16-36.a:31297 ec2-13-229-87-153:49627 ESTABLISHED



  • post-author-pic
    Sean G
    12-13-2018

    We block most public ports on the public side for security purposes. If you use the internal network between the servers though for testing you can use pretty much any port between the servers on your account.


    If you want to test with the public side, I believe ports 8000, 8080, and 3000 are open.

  • post-author-pic
    Kamlesh V
    12-14-2018

    Thanks. Can you add something in course as well?

Looking For Team Training?

Learn More