Skip to content

Instantly share code, notes, and snippets.

@usametov
Forked from mitchwongho/Docker
Last active April 16, 2021 21:26
Show Gist options
  • Save usametov/bc61b59c67ac928df895b20101585f09 to your computer and use it in GitHub Desktop.
Save usametov/bc61b59c67ac928df895b20101585f09 to your computer and use it in GitHub Desktop.
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
# without the /bin/ part
docker run -it ubuntu bash
# nothing else but bash...
docker run -it bash
#if image has a defined ENTRYPOINT. For these cases use:
docker run -it --entrypoint /bin/bash <image>
# save it as a new image like this:
$ docker commit <container_id> new_image_name:tag_name(optional)
# for the images w/o bash.
docker run -it --entrypoint /bin/sh
# If you want to interact with an existing container
docker exec -it <name> bash
# (alpine has sh)
docker exec -it <name> sh
# also, try entrypoint
...
"Cmd": [
"src/service.py"
],
"Entrypoint": [
"python"
],
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment