Taking a course that deals with these; the actual specifics is not pertinent to the course, but I generally have interest in trying to understand things regardless.
I have a docker-compose.yml file which I 'call on', or 'spin up'. The file contains the following information:
services:
redis:
image: redis:latest
expose:
- "6379"
sample0395:
image: sample0395/base:latest
stdin_open: true
tty: true
expose:
- "8888"
ports:
- "8888:8888"
From what I understand, and just based on the hierarchy as shown:
tty and stdin_open are analogous to the -t and -i arguments for the docker run command, respectively.
You use stdin_open when you need to work on a project outside the Docker container.
You use tty when you need to work on a project inside the Docker container.
To test this out, try running docker-compose up with either tty or stdin_open but not both and you'll find that with stdin_open you don't log in to the container's terminal while the opposite happens with tty.
As for your question regarding the difference between expose and ports, answers are found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With