Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with docker-compose #771

Closed
justin-pierce opened this issue Jul 6, 2019 · 11 comments · Fixed by #1008
Closed

Doesn't work with docker-compose #771

justin-pierce opened this issue Jul 6, 2019 · 11 comments · Fixed by #1008
Assignees
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue) question/docs ‽ Documentation clarification candidate to-merge ↰ Imminent
Milestone

Comments

@justin-pierce
Copy link

import time
from tqdm import tqdm

for i in tqdm(range(50), desc='debug'):
    time.sleep(0.1)

Then in terminal I see nothing until the loop has finished, and it just prints:

debug: 100% 50/50 [00:05<00:00, 9.81it/s]

My docker compose file has tty: true and os.isatty(sys.stdout.fileno()) returns true

@casperdcl
Copy link
Sponsor Member

Interesting. We provide a docker image
which seems to work fine for its intended use in CLI pipe mode.

What version of python are you using?

@justin-pierce
Copy link
Author

Image: FROM python:3.6

Which is running 3.6.6

Have tried it on two different computers and in both MacOS Terminal and VS Code Terminal.

@casperdcl casperdcl self-assigned this Jul 7, 2019
@casperdcl casperdcl added p2-bug-warning ⚠ Visual output bad to-fix ⌛ In progress labels Jul 7, 2019
@sepbot
Copy link

sepbot commented Jul 12, 2019

The problem is not with Docker itself, but Docker Compose.

To reproduce the problem, you need to first write a docker-compose.yaml file for your Docker service. Then bring up everything up by running docker-compose up -d and then following the logs by running docker-compose logs -f (or just run without -d, it will run in foreground I believe). If you follow these steps, you will find that the tqdm log line will not get outputted until a newline has been fed to stdout of that particular container after the loop has finished.

The problem is not present if you just use Docker itself with the --tty flag.

@casperdcl
Copy link
Sponsor Member

thanks @sepbot - is this something that's been reported on the docker-compose repo?

@casperdcl casperdcl added invalid ⛔ Not-an-issue or upstream (not-our-issue) and removed p2-bug-warning ⚠ Visual output bad to-fix ⌛ In progress labels Jul 12, 2019
@aneeshvartakavi
Copy link

I'm running into the same issue, are there any known workarounds or fixes for getting tqdm to work in docker compose?

@casperdcl casperdcl changed the title Doesn't work in Docker? Doesn't work with docker-compose Sep 17, 2019
@casperdcl casperdcl added the help wanted 🙏 We need you (discussion or implementation) label Sep 17, 2019
@shahidammer
Copy link

Did anyone manage to get the progress bar in the docker-compose. Any workaround?

@sepbot
Copy link

sepbot commented Oct 19, 2019

Use docker-compose run instead of docker-compose up and tty: true in your service config

@waydegg
Copy link

waydegg commented Jul 6, 2020

Use docker-compose run instead of docker-compose up and tty: true in your service config

Just using docker-compose run in my compose yml worked for me (tty: true made no noticeable difference).

@sepbot
Copy link

sepbot commented Jul 6, 2020

Use docker-compose run instead of docker-compose up and tty: true in your service config

Just using docker-compose run in my compose yml worked for me (tty: true made no noticeable difference).

You're right, docker-compose run allocates a TTY by default. Didn't know that at the time.

@casperdcl casperdcl added this to the v5.0.0 milestone Jul 7, 2020
@casperdcl casperdcl added question/docs ‽ Documentation clarification candidate to-merge ↰ Imminent and removed help wanted 🙏 We need you (discussion or implementation) labels Jul 7, 2020
casperdcl added a commit that referenced this issue Jul 19, 2020
casperdcl added a commit that referenced this issue Jul 19, 2020
@Ghost---Shadow
Copy link

Ghost---Shadow commented Jul 6, 2022

This workaround works fine too. For those who want to keep using docker compose up

it = tqdm(total=len(arr))
for e in arr:
  it.update(1)
  print(it)

@YuchiSu-Rin
Copy link

YuchiSu-Rin commented Mar 19, 2024

This command can help if you are running in detach mode:

docker compose up -d
docker attach --sig-proxy=false [container-name]

https://docs.docker.com/reference/cli/docker/container/attach/

You must set tty: true to the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid ⛔ Not-an-issue or upstream (not-our-issue) question/docs ‽ Documentation clarification candidate to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants