The arrangement of flags in your docker command matters!
In the official document of docker, commands are presented in the format of:
docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]
And the arrangement stated above must be followed, or else many kind of weird errors will occur.
Let's say you are trying to run a docker container interactively:
docker run {image} -it --entrypoint=sh -d
Guess what happens? Instead of running the image, it will instead show the following error:
getopt: invalid option -- 'i'
getopt: invalid option -- 't'
getopt: unrecognized option '--entrypoint=sh'
getopt: invalid option -- 'd'
This is because in the docker documentation, it specifically says to put the [options] - the flags such as -i, -t, or -d, right before IMAGE. Therefore, if we were to switch the position, we will be able to get the result we need. For example:
docker run -it --entrypoint=sh -d {image}
This should run the docker container in the background, while enable interactivity to our container.
Comments
Post a Comment