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

docker-compose exec Terminal output width is too narrow #273

Closed
heylookalive opened this issue Apr 11, 2018 · 6 comments
Closed

docker-compose exec Terminal output width is too narrow #273

heylookalive opened this issue Apr 11, 2018 · 6 comments

Comments

@heylookalive
Copy link

When using docker-compose exec... the terminal output is too narrow, see screenshot:
http://i68.tinypic.com/xlmc5y.jpg

Codebase

Drupal mounted codebase

Host OS

macOS High Sierra

Docker info output

Containers: 7
 Running: 7
 Paused: 0
 Stopped: 0
Images: 8
Server Version: 18.03.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 87
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: ITDI:5O55:TCQS:XJVO:BN6E:QX2H:A5JL:T7KL:TTF3:ZPMI:65WT:WNXE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 78
 Goroutines: 86
 System Time: 2018-04-11T15:24:24.807581168Z
 EventsListeners: 3
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Docker compose file

version: "2"

services:
  mariadb:
    image: wodby/mariadb:10.1-2.3.5
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal
    volumes:
      - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.

  php:
    image: wodby/drupal-php:7.0-3.3.1
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      PHP_FPM_CLEAR_ENV: "no"
      DB_HOST: mariadb
      DB_USER: drupal
      DB_PASSWORD: drupal
      DB_NAME: drupal
      DB_DRIVER: mysql
    volumes:
      - ./:/var/www/html

  nginx:
    image: wodby/drupal-nginx:7-1.13-3.0.1
    depends_on:
      - php
    environment:
      NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html
    volumes:
      - ./:/var/www/html
    labels:
      - 'traefik.backend=nginx'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:drupal.docker.localhost'

  pma:
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: mariadb
      PMA_USER: drupal
      PMA_PASSWORD: drupal
      PHP_UPLOAD_MAX_FILESIZE: 1G
      PHP_MAX_INPUT_VARS: 1G
    labels:
      - 'traefik.backend=pma'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:pma.drupal.docker.localhost'

  mailhog:
    image: mailhog/mailhog
    labels:
      - 'traefik.backend=mailhog'
      - 'traefik.port=8025'
      - 'traefik.frontend.rule=Host:mailhog.drupal.docker.localhost'

  portainer:
    image: portainer/portainer
    command: --no-auth -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - 'traefik.backend=portainer'
      - 'traefik.port=9000'
      - 'traefik.frontend.rule=Host:portainer.drupal.docker.localhost'

  traefik:
    image: traefik
    command: -c /dev/null --web --docker --logLevel=INFO
    ports:
      - '8000:80'
      - '8080:8080' # Dashboard
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

volumes:
  codebase:
@igorbiki
Copy link

Hi, I'm seeing same on my dev env. Also, you may want to check how long is your command line prompt when logged in to container, I had to add "COLUMNS=500" to my .bashrc file in php container. Since I did install new OS, I thought its specific to my env.

I'm using "docker-compose exec php bash" to login to container and then run drush / drupal (console) stuff.

@johandenhollander
Copy link

@heylookalive Are you sure this is not just a problem with drush?
Sometimes I have the same experience.
Just now with a drush updb -y command. But the drush ms command shows correctly...

@csandanov
Copy link
Member

We use -e COLUMNS=$COLUMNS -e LINES=$LINES fix at Wodby for Kubernetes commands, I guess we should add these to make shell command

@vstanchev
Copy link

I tried this in the Makefile:

shell:
        docker exec -ti -e COLUMNS=$(COLUMNS) -e LINES=$(LINES) $(shell docker ps --filter name='$(PROJECT_NAME)_php' --format "{{ .ID }}") sh

and it worked, but I noticed that $COLUMNS and $LINES are actually empty in the container shell, but not empty on my host shell.

Turns out setting them to empty also "fixes" the narrow shell issue.

shell:
        docker exec -ti -e COLUMNS= -e LINES= $(shell docker ps --filter name='$(PROJECT_NAME)_php' --format "{{ .ID }}") sh

Can someone elaborate on a possible reason why and how does that work? I'm on Linux with zsh.

@csandanov
Copy link
Member

COLUMNS and LINES are set by the shell, but not exported, which means that they are not added to the environment of subsequently executed commands.
SOURCE: https://stackoverflow.com/a/22588625/1826109

See referenced commit, we use tput to get the values.

I guess we'll see the fix in docker (moby) itself in the future moby/moby#35407

@csandanov
Copy link
Member

make shell fix with $COLUMNS has been added in 5.0.6 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants