Skip to content

Commit a6ef77b

Browse files
authored
Add ability to copy files to a container before it is started (#180)
1 parent c6aa87e commit a6ef77b

File tree

7 files changed

+285
-8
lines changed

7 files changed

+285
-8
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ const container = await new GenericContainer("postgres")
178178
.start();
179179
```
180180

181+
Copy a file to a container before it is started:
182+
183+
```javascript
184+
const { GenericContainer } = require("testcontainers");
185+
186+
const container = await new GenericContainer("postgres")
187+
.withExposedPorts(5432)
188+
.withCopyFileToContainer("/local/file.txt", "/remote/file1.txt")
189+
.withCopyContentToContainer("hello world", "/remote/file2.txt")
190+
.start();
191+
```
192+
181193
Creating a container with environment variables:
182194

183195
```javascript

package-lock.json

Lines changed: 212 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
},
3333
"dependencies": {
3434
"@types/dockerode": "^3.2.1",
35+
"archiver": "^5.2.0",
3536
"byline": "^5.0.0",
3637
"debug": "^4.3.1",
3738
"docker-compose": "^0.23.5",
@@ -45,6 +46,7 @@
4546
},
4647
"devDependencies": {
4748
"@elastic/elasticsearch": "^7.10.0",
49+
"@types/archiver": "^5.1.0",
4850
"@types/byline": "^4.2.32",
4951
"@types/debug": "4.1.5",
5052
"@types/glob": "^7.1.3",

0 commit comments

Comments
 (0)