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
Copy file name to clipboardExpand all lines: _assignments/assignment_03.md
+4
Original file line number
Diff line number
Diff line change
@@ -90,4 +90,8 @@ docker container prune
90
90
91
91
*__!!Attention!!__* This will delete all stopped containers on your system.
92
92
93
+
94
+
# Our changes
95
+
You can find our changes in the [`initial_dockerfile` branch](https://github.com/jfahrer/dockerizing_rails/tree/initial_dockerfile) and [compare it to the previous branch](https://github.com/jfahrer/dockerizing_rails/compare/initial_dockerfile)
Copy file name to clipboardExpand all lines: _assignments/assignment_08.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Assignment 8 - Iterating
2
-
Rebuilding the image every time we make changes is tedious and slows us down in our development workflow. But Docker wouldn't be Docker if we couldn't work around this problem. The solution here are so called bind mounts. A bind-mount allows us to mount a local file or directory into the containers file system. When using the Docker CLI, you can specify the bind-mount using the `-v` flag. With Docker Compose, we simply add the definition the `docker-compose.yml` via the `volumes` directive. Here is an example:
2
+
Rebuilding the image every time we make changes is tedious and slows us down in our development workflow. But Docker wouldn't be Docker if we couldn't work around this problem. The solution here are so called bind mounts. A bind-mount allows us to mount a local file or directory into the containers file system. For the Docker CLI, we can specify the bind-mount using the `-v` flag. With Docker Compose, we simply add the definition the `docker-compose.yml` via the `volumes` directive. Here is an example:
Copy file name to clipboardExpand all lines: _assignments/assignment_09.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ But before we make the change, let's try to get a `byebug` session from an actua
96
96
97
97
What should happen is that the Rails server stop and opens a `byebug` - but as you can tell, this doesn't work. The request is processed and http response is returned to our browser. This happens because by default the contains that are started with `docker-compose up` (as well as `docker-compose start` and `docker-compose restart`) don't have a tty attached and `byebug` can't hence not start the session.
98
98
99
-
We've seen that opening a byebug session works when we use `docker-compose run`. It does because Docker Compose will automatically attach a pseudo-tty for us and attach STDIN as well. So let's start the Rails server with `docker-compose run` instead. We have to first shut down the current app service, otherwise we will not be able to start a new Rails server because port 3000 is already in use.
99
+
We've seen that opening a byebug session works when we use `docker-compose run`. It does because Docker Compose will automatically attach a pseudo-tty for us and attach `STDIN` as well. So let's start the Rails server with `docker-compose run` instead. We have to first shut down the current app service, otherwise we will not be able to start a new Rails server because port 3000 is already in use.
100
100
```
101
101
docker-compose stop app
102
102
```
@@ -111,19 +111,19 @@ Since we defined the port mapping in our `docker-compose.yml` and `rails server`
111
111
docker-compose run --rm --service-ports app
112
112
```
113
113
114
-
If you now mark another todo as complete or active you will be dropped into a `byebug` session.
114
+
If we now mark another todo as complete or active we will be dropped into a `byebug` session.
115
115
116
-
You already know how to fix the issue. Go ahead and make the code change and make sure that the test passes.
116
+
We already know how to fix the issue. Go ahead and make the code change and make sure that the test passes.
117
117
118
118
## Making it work without stopping the server
119
-
Depending on your style of working, starting and stopping the container whenever we want to start a `byebug` session can might be tedious. The good news is that there is another way! We can add the following settings to our `app` service definition in the `docker-compose.yml`:
119
+
Depending on your style of working, starting and stopping the container whenever we want to start a `byebug` session might be tedious. The good news is that there is another way! We can add the following settings to our `app` service definition in the `docker-compose.yml`:
120
120
121
121
```yaml
122
122
tty: true
123
123
stdin_open: true
124
124
```
125
125
126
-
These to flags do what `docker-compose run` does for us automatically: They will attach a pseudo-tty to the container and keep STDIN open. You can find a complete example in `_examples/docker-compose.yml.with_tty`.
126
+
These to flags do what `docker-compose run` does for us automatically: They will attach a pseudo-tty to the container and keep `STDIN` open. You can find a complete example in `_examples/docker-compose.yml.with_tty`.
127
127
128
128
With these flags in place we can now restart our containers with
And there we go! If you press `ENTER` you will see that you are in a `byebug` session, just as before.
159
159
160
-
If we end the session by typing `continue`, we will see the Rails log on our screen - we are still attached to the container. In order to detach from the container you can use the key sequence `Ctrl-p` `Ctrl-q`. You could also `Ctrl-c`, but that would terminate the container and you would have to restart the service.
160
+
If we end the session by typing `continue`, we will see the Rails log on our screen - we are still attached to the container. In order to detach from the container we can use the key sequence `Ctrl-p` `Ctrl-q`. We could also press `Ctrl-c`, but that would terminate the container and we would have to restart the service.
161
161
162
162
__*Side note*__: The naming conventions of Docker Compose makes it pretty straight forward to "guess". I also recommend using command-line completion for Docker and [Docker compose](https://docs.docker.com/compose/completion/)
0 commit comments