docker container run -it : start new container interactively, opens a shell inside the container.
docker container exec -it - run additional command in existing running container as an additional process.
-it means:
-t : allocate a pseudo-tty. simualtes a real terminal,what ssh does.
-i : to keep terminal open to pass commands.
docker container run -it --name proxy nginx bash
The last bash is the argument we passed to run that command,the default program.
It will open a prompt and run the linux cmds directly.
like install a software:
apt-get install -y curl
>exit
will end the prompt and stop the container also.
To run the stopped container.:
docker container start -ai <cont_name>
-a --attach
-i --interactive
docker container exec -it mysql bash
as it creates a new process, existing mysql process doesn't effect.
alpine distribution:
----------------------------
docker pull alpine
docker image ls
docker container run -it alpine bash
gets error as bash doesn't exist.so use sh
apk is the package manager for alpine like apt-get for ubuntu.
docker container exec -it - run additional command in existing running container as an additional process.
-it means:
-t : allocate a pseudo-tty. simualtes a real terminal,what ssh does.
-i : to keep terminal open to pass commands.
docker container run -it --name proxy nginx bash
The last bash is the argument we passed to run that command,the default program.
It will open a prompt and run the linux cmds directly.
like install a software:
apt-get install -y curl
>exit
will end the prompt and stop the container also.
To run the stopped container.:
docker container start -ai <cont_name>
-a --attach
-i --interactive
docker container exec -it mysql bash
as it creates a new process, existing mysql process doesn't effect.
alpine distribution:
----------------------------
docker pull alpine
docker image ls
docker container run -it alpine bash
gets error as bash doesn't exist.so use sh
apk is the package manager for alpine like apt-get for ubuntu.
No comments:
Post a Comment