Skip to content

Instantly share code, notes, and snippets.

@ashok-arora
Created January 1, 2022 10:29
Show Gist options
  • Save ashok-arora/2fed78090191543a4eb60367fb495306 to your computer and use it in GitHub Desktop.
Save ashok-arora/2fed78090191543a4eb60367fb495306 to your computer and use it in GitHub Desktop.

Accessing a Docker container

Step 1: Run a container using an existing image

ashok@Ashoks-Mac-mini ~ % docker run --name p39 -it python:3.9-slim
Python 3.9.9 (main, Dec 21 2021, 06:58:41)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Step 2: Execute bash shell inside the running container

ashok@Ashoks-Mac-mini ~ % docker exec -it p39 /bin/bash
root@5383c4e2379c:/# gcc
bash: gcc: command not found
root@5383c4e2379c:/#

Note: Commands can't be executed inside stopped containers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment