首页 > 解决方案 > 来自守护进程的错误响应:当我尝试在容器内提交更改时未能获得摘要:第 1 部分

问题描述

我想设置一个脚本,将更改提交到 docker 映像。我正在学习如何阅读这篇文章:

脚本完成后如何运行 docker 容器并提交更改?

我做了一些修改以使其适合我的场景。

这是我的“env_setup_script.sh”脚本:

开始.sh:

#!/bin/bash
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
sudo service docker start

hostusername=$(whoami)

echo -n " Hello, whats your name ?"
read -r
username=$REPLY

docker run \
 --gpus all \
 --rm -it \
 -v $XSOCK:$XSOCK:rw \
 -v $XAUTH:$XAUTH:rw \
 -e DISPLAY=$DISPLAY \
 -e XAUTHORITY=$XAUTH \
 -v /:/home/$username/Shared-$hostusername \
 -t firefox/docker

根据帖子,这是我的:

提交.sh:

#!/bin/bash

# Run a docker with the env boot script

./start.sh

# Get the container ID of the last run docker (above)

export CONTAINER_ID=\docker ps -lq``

echo $CONTAINER_ID

# Commit the container state (returns an image_id with sha256: prefix cut off)# and write the IMAGE_ID to disk at ~/.docker_image_id

(docker commit $CONTAINER_ID | cut -c8-) > docker_image_id

不幸的是它不起作用:

# ./commit.sh    

Hello, whats your name ? mario

# apt install geditReading package lists... DoneBuilding dependency tree        Reading state information... Done

The following additional packages will be installed: gedit-common gir1.2-gtksource-4 gir1.2-peas-1.0 libamtk-5-0 libamtk-5-common libgspell-1-2 libgspell-1-common libgtksourceview-4-0 libgtksourceview-4-common libpeas-1.0-0 libpeas-common libtepl-4-0 python3-gi-cairoSuggested packages: gedit-pluginsThe following NEW packages will be installed: gedit gedit-common gir1.2-gtksource-4 gir1.2-peas-1.0 libamtk-5-0 libamtk-5-common libgspell-1-2 libgspell-1-common libgtksourceview-4-0 libgtksourceview-4-common libpeas-1.0-0 libpeas-common libtepl-4-0 python3-gi-cairo0 upgraded, 14 newly installed, 0 to remove and 7 not upgraded.Need to get 1218 kB of archives.After this operation, 9606 kB of additional disk space will be used.Do you want to continue? [Y/n] y

.....

root@c52cc7395c5d:/# exitexit

84bf2f08ac45

Error response from daemon: failed to get digest

sha256:f749b9fd92b430df6783496eaa814c63bd06a7cb5a5914611f10b8f665a5d134: open /var/lib/docker/image/overlay2/imagedb/content/sha256/f749b9fd92b430df6783496eaa814c63bd06a7cb5a5914611f10b8f665a5d134: no such file or directory

标签: bashdockershcommit

解决方案


推荐阅读