docker / cli

The Docker CLI
Apache License 2.0
4.94k stars 1.93k forks source link

Column size calculation seems off when there are non-English characters in a description #3421

Closed masterl closed 1 year ago

masterl commented 2 years ago

Description

Looks like when using docker search if a description has non-English characters, the column sizes are calculated wrong.

Steps to reproduce the issue:

  1. docker search gitlab

Describe the results you received:

NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
gitlab/gitlab-ce                             GitLab Community Edition docker image based …   3518                 [OK]
sameersbn/gitlab                             Dockerfile to build a GitLab image for the D…   1183                 [OK]
gitlab/gitlab-runner                         GitLab CI Multi Runner used to fetch and run…   761                  [OK]
gitlab/gitlab-ee                             GitLab Enterprise Edition docker image based…   304                  
twang2218/gitlab-ce-zh                       汉化的 GitLab 社区版 Docker Image                     254                  [OK]
jangrewe/gitlab-ci-android                   GitLab CI image for building Android apps       63                   [OK]

Describe the results you expected:

NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
gitlab/gitlab-ce                             GitLab Community Edition docker image based …   3518                 [OK]
sameersbn/gitlab                             Dockerfile to build a GitLab image for the D…   1183                 [OK]
gitlab/gitlab-runner                         GitLab CI Multi Runner used to fetch and run…   761                  [OK]
gitlab/gitlab-ee                             GitLab Enterprise Edition docker image based…   304                  
twang2218/gitlab-ce-zh                       汉化的 GitLab 社区版 Docker Image                 254                  [OK]
jangrewe/gitlab-ci-android                   GitLab CI image for building Android apps       63                   [OK]

Additional information you deem important (e.g. issue happens only occasionally):

-

Output of docker version:

Client:
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.17.5
 Git commit:        e91ed5707e
 Built:             Mon Dec 13 22:31:40 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.5
  Git commit:       459d0dfbbb
  Built:            Mon Dec 13 22:30:43 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.5.9
  GitCommit:        1407cab509ff0d96baa4f0eb6ff9980270e6e620.m
 runc:
  Version:          1.1.0
  GitCommit:        v1.1.0-0-g067aaf85
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
  compose: Docker Compose (Docker Inc., 2.2.3)
  scan: Docker Scan (Docker Inc., v0.1.0-227-g061fe0a0c5)

Server:
 Containers: 5
  Running: 0
  Paused: 0
  Stopped: 5
 Images: 19
 Server Version: 20.10.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1407cab509ff0d96baa4f0eb6ff9980270e6e620.m
 runc version: v1.1.0-0-g067aaf85
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.19-1-MANJARO
 Operating System: Manjaro Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 23.36GiB
 Name: leonardo-desk-br
 ID: ETWP:26XK:W6AD:2M5C:HGEH:KN4T:P6JR:NKVM:GCTG:P6L3:YDJ2:MGWV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):

My own desktop running Manjaro. Using official docker package.

masterl commented 2 years ago

Found another example:

docker search ldap:

NAME                                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ldapaccountmanager/lam                LDAP Account Manager                            65                   
linuxserver/ldap-auth                                                                 60                   
wheelybird/ldap-user-manager          A modern LDAP web GUI user manager and group…   17                   [OK]
sharaku/ldap                          ldapサーバ、phpLDAPadmin、CLIを提供するコン…                14                   [OK]
openfrontier/ldap-ssp                 LDAP Tool Box Self Service Password             13                   [OK]
dwimberger/ldap-ad-it                 Simple LDAP server simulating AD for integra…   13                   [OK]
ndeloof commented 2 years ago

Docker CLI relies on go standard library tabWritter to compute column width. This one consider a rune to be a single-cell character (like Latin characters) - which is wrong. Maybe we should switch to https://github.com/WeiZhang555/tabwriter?

ndeloof commented 2 years ago

reported https://github.com/golang/go/issues/51650

ndeloof commented 2 years ago

based on https://github.com/golang/go/issues/8273#issuecomment-378849764, it seems there's no deterministic way we could address this issue :'(

masterl commented 2 years ago

Yeah. I just finished reading that issue. :(

thaJeztah commented 1 year ago

This should be fixed by https://github.com/docker/cli/pull/3568