You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the container starts as *root* user. It means, that all produced files
60
+
By default, Go container starts as a*root* user. It means, that all produced files
59
61
will be owned by `root:root` user.
60
62
61
-
To set files to be owned by your current user by default, you need to start
62
-
the container with your current **uid/gid**.
63
+
To set files to be owned by your current user by default, start the container with your current **uid/gid**.
63
64
64
65
Use `-u` flag to start container with different user/group id.
65
66
66
-
```bash
67
+
```shell
67
68
# Start container as other uid/gid
68
69
docker exec --rm -it -u "$UID:$GID" ...
69
70
```
70
71
71
-
**Attention:** we recommend to mount your host GOPATH and GOCACHE instead of
72
-
separated volumes approach when using UID/GID other than root.
72
+
> [!IMPORTANT]
73
+
> For non-root container user, it is recommended to mount your host GOPATH and GOCACHE.
73
74
74
75
### Go Build Cache
75
76
76
-
In order to speed up build times and keep Go build cache, you can mount your Go build cache directory or create a separate Docker volume for it.
77
+
In order to speed up build times and keep Go build cache, it is recommended to mount local Go build cache directory or create a separate Docker volume for it.
77
78
78
-
**Local GOPATH**
79
+
**Mounting local GOPATH:**
79
80
80
-
```bash
81
+
```shell
81
82
docker run --rm -it \
82
83
-u $UID \
83
84
-v /YourPackageSrc:/go/work \
@@ -87,9 +88,9 @@ docker run --rm -it \
87
88
x1unix/go-mingw go build .
88
89
```
89
90
90
-
**Volume:**
91
+
**Using Docker volume:**
91
92
92
-
```bash
93
+
```shell
93
94
# Create Docker volume
94
95
docker volume create go-cache
95
96
@@ -102,7 +103,8 @@ docker run --rm -it \
102
103
x1unix/go-mingw go build .
103
104
```
104
105
105
-
See [Docker volumes docs](https://docs.docker.com/storage/volumes/) for more info.
106
+
> [!TIP]
107
+
> See [Docker volumes docs](https://docs.docker.com/storage/volumes/) for more info.
106
108
107
109
### Go modules cache
108
110
@@ -113,10 +115,12 @@ To do this, mount your GOPATH or Go modules directory (`$GOPATH/pkg`).
113
115
114
116
### Building custom Docker image
115
117
116
-
You can build image locally with specified Go version:
118
+
Docker image can be rebuilt locally with a desired Go version:
0 commit comments