4

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:

  • redis and sample0395 are 'services'
  • redis:latest and sample0395/base:latest are the image_name:tag combinations
  • expose and ports: list the ports (not sure what the difference is or what the significance is of the difference between these two)
  • I have no idea what stdin_open or tty do, and cannot seem to get an understanding through google.

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This helps. Could you please share examples of working on a project from outside the container vs inside the container?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.