We you run a docker image using the docker run command you may not get the complete Sha256 of the Container ID of the container just created by default.
There are multiple ways in which you can get the Container ID, let's try to cover most of them,
- Using the Docker inspect Command
- Using the --no-trunc Option with docker ps -a
- Using the --cidfile Option
- When running the Image in Detached Mode
$ docker run -it alpine
# exit
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac7e6a0e8c66 alpine "/bin/sh" About a minute ago Exited (0) About a minute ago silly_bartik
$ docker inspect ac7e6a0e8c66 | grep Image
"Image": "sha256:a6215f271958c760a2975a6765016044115dbae4b90f414eba3a448a6a26b4f6",
"Image": "alpine", |

Simply add the option --no-trunc along with the docker ps command to get a non-truncated output, which will print out full sha256 value for the containers,
% docker ps --no-trunc -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
53b2401f00cf5043c9020eb02277dfd0347a2b0283641cae72a80b4c7ee2d880 alpine "/bin/sh" 6 minutes ago Exited (0) 6 minutes ago lucid_payne
8b47cb64a8e271c1956b828cce37f332e4c6071136bf33dc0971e872c089755a alpine "/bin/sh" 11 minutes ago Exited (0) 11 minutes ago keen_brown

If you pass in --cidfile option and pass a filename, you can write the Sha256 Container ID to a file on your host.
% docker run -it --cidfile ~/Desktop/containerId.txt alpine
/ # exit
% cat ~/Desktop/containerId.txt
8b47cb64a8e271c1956b828cce37f332e4c6071136bf33dc0971e872c089755a

When you run a Docker Image in detached mode (--detach -d options) the container ID will be printed on the console.
% docker run -d alpine
53b2401f00cf5043c9020eb02277dfd0347a2b0283641cae72a80b4c7ee2d880
