# Docker

#### Docker enable gpu

```
docker run -it --gpus all --name jason_dl -p 8888:8888 
pytorch/pytorch:2.9.0-cuda12.8-cudnn9-runtime /bin/bash
```

#### Open Jupyter notebook

```
docker run -it -p 8888:8888 image:version
jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --allow-root
```

#### Docker fetch image

```
docker pull image_name
```

#### Docker list all images

```
docker images -a
```

#### Docker add host dir to docker container dir

```
docker run -it --name=example1 -v from_dir:dest_dir
```

#### Docker enter running container

```
docker exec -it container_id /bin/bash
```

#### Restart docker

```
killall Docker && open /Applications/Docker.app
```

#### Copy file from container to host

```
docker cp <containerId>:/file/path/within/container /host/path/target
```

#### Commit a image from a container

```
docker commit <container_id> docker_username/new_image_name:new_tag
```

#### Login a docker account

```
docker login
```

#### Push new image to docker hub

```
docker push docker_username/new_image_name:new_tag
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://juechen-yang.gitbook.io/juechen-s-codebook/docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
