Skip to content

Commit ee0fa56

Browse files
committed
Include a devcontainer.json
1 parent c3307d7 commit ee0fa56

File tree

4 files changed

+24
-47
lines changed

4 files changed

+24
-47
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated file
2+
.devcontainer/

Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
FROM ruby:3.0
2-
WORKDIR /usr/src/app
3-
# CMD ["./your-daemon-or-script.rb"]
4-
# ENV PORT 3000
2+
WORKDIR /root
53
EXPOSE 3000
6-
ENTRYPOINT [ "/bin/bash" ]
4+
# Keep container running https://devopscube.com/keep-docker-container-running/
5+
ENTRYPOINT ["tail", "-f", "/dev/null"]

devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "ruby-server-container",
3+
"forwardPorts": [3000],
4+
"build.dockerfile": "./Dockerfile"
5+
}

notes.md

+14-43
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
2-
# Ruby official container
3-
4-
https://hub.docker.com/_/ruby
5-
6-
7-
Dockerfile
8-
9-
```
10-
FROM ruby:3.0
11-
WORKDIR /usr/src/app
12-
# CMD ["./your-daemon-or-script.rb"]
13-
# ENV PORT 3000
14-
# EXPOSE $PORT
15-
ENTRYPOINT [ "/bin/bash" ]
16-
```
17-
1+
# Creating a Docker container with Ruby on it
182

193
Create the docker image
204
```
@@ -27,46 +11,33 @@ docker create --name ruby-server --publish 3000:3000 ruby-image
2711
```
2812

2913
Start the container
30-
This starts it and exits immediately (!!!)
3114
```
32-
docker start webdev-nutshell
33-
```
34-
35-
36-
Start the container (detached iteractive)
37-
https://stackoverflow.com/a/31143261/446681
38-
```
39-
docker run -dit -p 3000:3000 --name ruby-server ruby-image
40-
41-
15+
docker start ruby-server
4216
```
4317

44-
4518
SSH into the container
4619
```
4720
docker exec -it ruby-server /bin/bash
4821
```
4922

5023

51-
TODO: Port binding in docker is not working
52-
See https://stackoverflow.com/questions/54940990/docker-cant-connect-to-container-exposed-port
53-
54-
55-
# Docker build
56-
57-
https://docs.docker.com/engine/reference/commandline/build/
58-
59-
```
60-
docker build - < Dockerfile
61-
62-
```
63-
64-
6524
# VS Code Docker Extension
6625
https://code.visualstudio.com/docs/devcontainers/containers
6726
https://code.visualstudio.com/docs/devcontainers/tutorial
6827
https://code.visualstudio.com/docs/devcontainers/create-dev-container
6928

29+
https://containers.dev/implementors/json_reference/
30+
https://containers.dev/implementors/reference/
31+
32+
# Docker
33+
Docker Hub https://hub.docker.com/_/ruby
34+
Keep container running https://devopscube.com/keep-docker-container-running/
35+
36+
Start the container (detached iteractive)
37+
https://stackoverflow.com/a/31143261/446681
38+
```
39+
docker run -dit -p 3000:3000 --name ruby-server ruby-image
40+
```
7041

7142

7243
# Misc

0 commit comments

Comments
 (0)