# Lab #1: Tạo một hình ảnh có cài đặt GIT

### Tạo Dockerfile

{% code title="terminal" lineNumbers="true" %}

```sh
FROM alpine:3.5
RUN apk update
RUN apk add git
```

{% endcode %}

### Xây dựng hình ảnh Docker

{% code title="terminal" lineNumbers="true" %}

```sh
docker build -t ajeetraina/alpine-git .
```

{% endcode %}

### Gắn thẻ hình ảnh là labs-git

{% code title="terminal" lineNumbers="true" %}

```sh
docker tag ajeetraina/alpine-git ajeetraina/labs-git:v1.0
```

{% endcode %}

### Xác minh hình ảnh

{% code title="terminal" lineNumbers="true" %}

```sh
$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
ajeetraina/alpine-git   latest              cb913e37a593        16 seconds ago      26.6MB
ajeetraina/labs-git     v1.0                cb913e37a593        16 seconds ago      26.6MB
```

{% endcode %}

### Tạo một thùng chứa

{% code title="terminal" lineNumbers="true" %}

```sh
docker run -itd ajeetraina/labs-git:v1.0 /bin/sh
```

{% endcode %}

{% code title="terminal" lineNumbers="true" %}

```sh
$ docker ps
CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS               NAMES
3e26a5268f55        ajeetraina/labs-git:v1.0   "/bin/sh"           4 seconds ago       Up 2 seconds                            elated_neumann
```

{% endcode %}

### Nhập vào vỏ container

{% code title="terminal" overflow="wrap" lineNumbers="true" %}

```sh
docker attach 3e26
```

{% endcode %}

Vui lòng nhấn phím “Enter” hai lần để nhập vào vỏ container

### Xác minh xem GIT đã được cài đặt chưa

{% code title="terminal" overflow="wrap" lineNumbers="true" %}

```shell
/ # git --version
git version 2.13.7
```

{% endcode %}

{% code title="Tài liệu tham khảo" overflow="wrap" lineNumbers="true" %}

```
https://dockerlabs.collabnix.com/beginners/dockerfile/lab1_dockerfile_git.html
```

{% endcode %}


---

# 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://blogs.nhquydev.net/devsecops/docker/dockerfile/lab-1-tao-mot-hinh-anh-co-cai-dat-git.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.
