Anatomy of docker run

As explained in Docker API, docker run command comprises of several API calls. Also seen in run.go, first the image is pulled if it is not locally available, then create container, attach to the container (if not detached), start the container, and wait.

So it is possible to simulate docker run with a combination of docker create, docker start, and docker logs:

[code language=”bash”]

#docker logs $(docker start $(docker create centos bash -c "date > /dev/null"))

[/code]

This could help write a docker run using Docker API in Go

Leave a Reply