Hot answers tagged

30

Docker's EXPOSE documentation addresses this specific point: The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use ...


30

You can use the Ansible wait_for module which checks a specific TCP port is open. Since in this case, all ports should be open already, we can use a minimal no. of retries, just enough to cover network issues: - name: Check all port numbers are accessible from the current host wait_for: host: mywebserver.com port: "{{ item }}" state: ...


5

Disclaimer: I'm not using Ansible. What I would do is use a random "predictable" number. According to Ansible doc you can seed the random number generator: As of Ansible version 2.3, it’s also possible to initialize the random number generator from a seed. This way, you can create random-but-idempotent numbers: "{{ 59 |random(seed=...


4

This is done for automation sake. You can have a universal command that runs docker run -P to start a container and the Dockerfile itself is used to specify which container exposes which port. In case you are dealing with dozens or hundreds of containers being built through a pipeline, this is quite useful. Passing external details not contained in ...


3

The cure (or bandaid) was to set Pipelining=False in the ansible.cfg file. This kind of stinks because I like Pipelining and it works, but I guess ansible is gonna treat that first ssh statement as something 'it owns' even though it's a local action.


3

You did everything right, it is the correct InSpec test and use with Docker! You encountered a bug in InSpec that is related to InSpec's netstat output parsing combination with Alpine's netstat output. See InSpec's output for postgres container instead of postgres:alpine: $ inspec exec docker_test.rb -t docker://1c8162517c22 ...


2

Most likely the port is published on the VM and you are trying to connect to your laptop's IP and not seeing it. Newer versions of docker that use xhyve include some networking tricks to publish the port all the way to your laptop, but docker-machine with VirtualBox does not do this. You can lookup the IP of your VM with docker-machine ls or see it in the ...


2

AFAIK there is no built-in module for this purpose, but you can use shell + nc: --- - hosts: all tasks: - shell: nc -z -w 1 -G 1 my.hostname.com {{ item }} || echo "Port {{ item }} is closed" with_items: [80,443,8443]


2

You can add, if it's not already the case, a frontal, rev proxy, to prevent direct access to the TS. This could also add an authentication layer... I am not a lot in Microsoft stuff so this is really a basic advice. If TS allow the use of pubkey instead of passwd this would be a good addition too.


1

On Linux, containers live in separate network namespaces, so localhost or 127.0.0.1 on the container is not localhost on the host. I'm not sure about other OSes. You could expose a port to the host like this: docker run -p 3306:3306 mysql Then you can access it from any container at the host IP address, which for the default network is 172.17.0.1:3306. You ...


1

When you use network_mode host, the published ports are ignored, which means the ports that are open in the containers will be the same port in the host. Does not matter what you had declared in ports The default behavior is every service in the compose can talk to each other. Links are not required to enable services to communicate - by default, any ...


1

One way to achieve this is by using the MySQL socket to connect instead of port. For this you would have bind a mount to your container. You would anyway need a host directory bound to container to persist Database data. First create a directory on host to mount container /var/lib/mysql Use -v option in docker run to attach host path to container Connect ...


1

By default Docker uses the bridge network. On a default Docker installation you can simply map a port to the container's service port. The Redis Docker image exposes its service on port 6379 so you can do: $ docker run --name rd -d -p 6379:6379 redis:latest From your host you can now run use the redis-cli utility: $ redis-cli 127.0.0.1:6379> ping PONG ...


1

It is possible on the Linux(Unix) bastion host. Step-1: First ssh to the bastion host. eg. 16.23.14.20 is the bastion host. # ssh root@16.23.14.20 Step-2: Create port tunneling by using the below command. eg. The RDS IP is 172.16.13.10 # ssh -L 3006:172.16.13.10:3006 localhost Verify using netstat command. netstat -ntulp | grep 3006 Note: If netstat ...


1

Since you are using the tag "Docker-Machine" I'm assuming that you are using Docker Toolbox to manage Docker. The problem is most likely an issue with Virtual Box configuration than your Docker configuration. When you try pinging your container on port 9001, use the ip 0.0.0.0 instead of 127.0.0.1 or localhost. Another way to test would be to get the IP ...


1

This should be fine. It's something you may even have to do if ports are already in use on localhost. Even development languages like .net core are now supporting different environments that can be used to configure the different ports. Example: 1433 is the standard sql server port. If I wanted to test a local sql server container, but did not want to ...


1

iptables will probably scale better than socat because socat runs completely in user space. There's a common impression that iptables is hard to deal with, but I find it easier that most routers to fiddle with. There are a number of iptables wrappers available to make it easier to handle. If you're willing to accept the performance hit of running in user ...


Only top voted, non community-wiki answers of a minimum length are eligible