Error: /docker-import-012345678/bin/json: no such file or directory
What Steps Lead to the Docker /bin/json Error?
During the process of importing a Docker image, the following steps were executed, which resulted in an error.
Steps Performed
- Switched to the Docker image directory path:
cd docker/directory/image-path
- Ran the Docker load command to import the image:
cat docker_custom_image.tar | docker load
- After executing the command, the following error occurred:
“open /var/lib/docker/tmp/docker-import-622414428/bin/json: no such file or directory“
Why Does This Error Occur?
This error occurs when docker load is used with an image created using docker export.
Modern versions of Docker strictly validate image metadata.
Images created with docker export do not contain the required layered structure and metadata files.
As a result, Docker fails to load the image and throws the /bin/json error.
What Is the Correct Docker Image Workflow?
Docker image commands must always be used in matching pairs.
- docker save –> docker load
- docker export –> docker import
Using the wrong combination leads to missing files such as manifest.json.
How Can This Issue Be Fixed?
One commonly suggested approach to fix this issue is to manually create the tmp directory inside /var/lib/docker/.
However, in this case, this solution did not resolve the problem. Further investigation was required to identify the correct fix.
The root cause was the incorrect Docker image import method.
If the image was originally created using docker export, it must be imported using docker import instead of docker load.
Correct Command
cat docker_custom_image.tar | docker import - custom_docker/image:latest
After running this command, verify the image using:
docker images
Why Are Manual Fixes Not Recommended?
Some older solutions suggest manually creating /var/lib/docker/tmp.
This is not recommended because:
- Docker manages system directories internally
- Manual changes can cause permission or security issues
- The root cause of the error remains unresolved
Frequently Asked Questions (FAQs)
Why does Docker complain about /bin/json?
Because the tar file lacks required image metadata.
Is this error related to Docker bugs?
No. It’s expected behavior based on image format.
What’s the safest way to move images today?
Use docker save and docker load.
No. It’s expected behavior based on image format.
What’s the safest way to move images today?
Use docker save and docker load.
Conclusion
The /bin/json error is not a Docker bug.
It is caused by a mismatch between image creation and import commands.
Using the correct Docker workflow ensures compatibility with modern Docker versions and prevents this issue.
We would love the hear your thoughts, suggestions, and questions in the comments below !!