Docker UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position

  • A+
所属分类:linux技术
摘要

 在容器里查询nova服务的时候字符集报错问题留档及处理方法: 1、在容器里执行nova list –all 提示

 在容器里查询nova服务的时候字符集报错问题留档及处理方法:

1、在容器里执行nova list --all 提示

[root@stack1 region_01]# nova list --all

ERROR (UnicodeEncodeError): 'ascii' codec can't encode characters in position 4418-4419: ordinal not in range(128)

[root@stack1 region_01]# nova list

ERROR (UnicodeEncodeError): 'ascii' codec can't encode characters in position 3718-3719: ordinal not in range(128)

[root@stack1 region_01]#

Docker UnicodeEncodeError: 'ascii' codec can't encode characters in position

 排查及处理思路如下:

1、退出容器,查询宿主机字符集locale的设置为en_US.UTF-8:

Docker UnicodeEncodeError: 'ascii' codec can't encode characters in position

 

[root@stack1 region_01]# exit

[root@stack1 ~]# locale

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

[root@stack1 ~]#

2、进入刚执行命令报错的容器,手工修改命令行的编码utf-8,保持跟宿主机一致,此时再执行nova list查询命令恢复正常。

[root@stack1 ~]# docker exec -it kolla-ansible-deploy /bin/bash

[root@stack1 region_01]# export LANG=en_US.UTF-8

[root@stack1 region_01]# nova list --all

ERROR (CommandError): You must provide a user name/id (via --os-username, --os-user-id, env[OS_USERNAME] or env[OS_USER_ID]) or an auth token (via --os-token).

[root@stack1 region_01]#

[root@stack1 region_01]# source admin-openrc.sh

[root@stack1 region_01]#

[root@stack1 region_01]# nova list --all

+--------------------------------------+-------------------------+----------------------------------+---------+------------+-------------+------------------------------------------------------------------------------+

| ID | Name | Tenant ID | Status | Task State | Power State | Networks |

+--------------------------------------+-------------------------+----------------------------------+---------+------------+-------------+------------------------------------------------------------------------------+

| 06febeeb-f41d-464e-814f-4732e95e6e77 | DB | c4dca344d4b9436aa1cb15c6a54a2c6b | ACTIVE | - | Running | manage_net=

Docker UnicodeEncodeError: 'ascii' codec can't encode characters in position

 

文章最后,给大家分享几个有关微软全家桶学习参考链接,希望可以帮忙有需要的朋友。

Docker UnicodeEncodeError: 'ascii' codec can't encode characters in position