Multi stage build retain environment and entrypoint

Did you compare entrypoint, cmd and envs from the base image with your custom image?

docker pull jupyter/datascience-notebook:hub-3.1.1
docker image inspect jupyter/datascience-notebook:hub-3.1.1 --format '{{json .Config.Entrypoint }}'
docker image inspect jupyter/datascience-notebook:hub-3.1.1 --format '{{json .Config.Cmd }}'
docker image inspect jupyter/datascience-notebook:hub-3.1.1 --format '{{json .Config.Env }}'

Then do the same for your custom image.

Note: If jq is installed in your system, you can add | jq to the end of the commands for better readability.