Docker build -t t. encountered strange problems after failure

  docker, question

Dockerfile

FROM ubuntu
 RUN apt-get update && apt-get install -y mysql-server php5 php5-xdebug

Creation failed because several packages could not be found.
docker build -t docker_image1 .

E: Package ‘php5’ has no installation candidate
E: Unable to locate package php5-xdebug

This operation generated an image with no name
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 77d786364eba 25 minutes ago 122 MB

Cannot delete because a container is using it.
docker rmi 77d7 -f
Error response from daemon: Conflict, cannot delete 77d786364eba because the container c4283c57025d is using it, use -f to force
Error response from daemon: No such image: -f
FATA[0000] Error: failed to remove one or more images

docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4283c57025d 77d786364ebafecb599657f5d96053e5fb6829f22129e5002b3e3eddb672b7ae:latest “/bin/sh -c ‘apt-get 28 minutes ago Exited (100) 4 minutes ago reverent_goodall

docker start c428
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4283c57025d 77d786364ebafecb599657f5d96053e5fb6829f22129e5002b3e3eddb672b7ae:latest “/bin/sh -c ‘apt-get 28 minutes ago Up 2 seconds reverent_goodall

After starting the container, why can’t you connect it?
I’ve tried many times, but I can’t. Can only delete containers and mirrors, and cannot make modifications based on c428 mirrors?

Just now, it was clearly shown that it had already started. Why can’t it be connected?
docker attach c428
FATA[0000] You cannot attach to a stopped container, start it first

Docker ps found the container stopped at this time. The container was started successfully, the connection failed, and the container stopped automatically at the same time. What is the situation?

Has anyone met?

Usedocker buildWhen you build a mirror, you actually create a container based on the underlying mirror, run the first instruction in this container, and then save it as a mirror and delete the container. After that, a container is created based on the new image, and a second instruction is executed to save it as an image, delete the container, and delete the previous image (only the image information is deleted, and the image layer is not deleted). If you repeat and know the end of the last instruction, you will get the target image.

If there is an accident during the construction process, the next container that exits unexpectedly and the mirror image on which it depends will remain. In fact, these are all useless things, we can delete them directly. Because the container depends on the mirror, delete the container before deleting the mirror.