Merge pull request #1 from arielsafari/patch-1
Add "Unix/Windows" support for shell commands
This commit is contained in:
commit
62333ce0f0
@ -40,6 +40,8 @@ For now, we will create the network first and attach the MySQL container at star
|
|||||||
1. Start a MySQL container and attach it the network. We're also going to define a few environment variables that the
|
1. Start a MySQL container and attach it the network. We're also going to define a few environment variables that the
|
||||||
database will use to initialize the database (see the "Environment Variables" section in the [MySQL Docker Hub listing](https://hub.docker.com/_/mysql/)).
|
database will use to initialize the database (see the "Environment Variables" section in the [MySQL Docker Hub listing](https://hub.docker.com/_/mysql/)).
|
||||||
|
|
||||||
|
=== "Unix"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--network todo-app --network-alias mysql \
|
--network todo-app --network-alias mysql \
|
||||||
@ -48,9 +50,7 @@ For now, we will create the network first and attach the MySQL container at star
|
|||||||
-e MYSQL_DATABASE=todos \
|
-e MYSQL_DATABASE=todos \
|
||||||
mysql:5.7
|
mysql:5.7
|
||||||
```
|
```
|
||||||
|
=== "Windows"
|
||||||
If you are using PowerShell then use this command.
|
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
docker run -d `
|
docker run -d `
|
||||||
--network todo-app --network-alias mysql `
|
--network todo-app --network-alias mysql `
|
||||||
@ -178,6 +178,8 @@ With all of that explained, let's start our dev-ready container!
|
|||||||
|
|
||||||
1. We'll specify each of the environment variables above, as well as connect the container to our app network.
|
1. We'll specify each of the environment variables above, as well as connect the container to our app network.
|
||||||
|
|
||||||
|
=== "Unix"
|
||||||
|
|
||||||
```bash hl_lines="3 4 5 6 7"
|
```bash hl_lines="3 4 5 6 7"
|
||||||
docker run -dp 3000:3000 \
|
docker run -dp 3000:3000 \
|
||||||
-w /app -v "$(pwd):/app" \
|
-w /app -v "$(pwd):/app" \
|
||||||
@ -189,9 +191,7 @@ With all of that explained, let's start our dev-ready container!
|
|||||||
node:12-alpine \
|
node:12-alpine \
|
||||||
sh -c "yarn install && yarn run dev"
|
sh -c "yarn install && yarn run dev"
|
||||||
```
|
```
|
||||||
|
=== "Windows"
|
||||||
If you are using PowerShell then use this command.
|
|
||||||
|
|
||||||
```powershell hl_lines="3 4 5 6 7"
|
```powershell hl_lines="3 4 5 6 7"
|
||||||
docker run -dp 3000:3000 `
|
docker run -dp 3000:3000 `
|
||||||
-w /app -v "$(pwd):/app" `
|
-w /app -v "$(pwd):/app" `
|
||||||
|
@ -37,6 +37,7 @@ So, let's do it!
|
|||||||
1. Make sure you don't have any previous `getting-started` containers running.
|
1. Make sure you don't have any previous `getting-started` containers running.
|
||||||
|
|
||||||
1. Run the following command. We'll explain what's going on afterwards:
|
1. Run the following command. We'll explain what's going on afterwards:
|
||||||
|
=== "Unix"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -dp 3000:3000 \
|
docker run -dp 3000:3000 \
|
||||||
@ -45,7 +46,7 @@ So, let's do it!
|
|||||||
sh -c "yarn install && yarn run dev"
|
sh -c "yarn install && yarn run dev"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using PowerShell then use this command.
|
=== "Windows"
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
docker run -dp 3000:3000 `
|
docker run -dp 3000:3000 `
|
||||||
|
@ -51,8 +51,9 @@ And now, we'll start migrating a service at a time into the compose file.
|
|||||||
|
|
||||||
To remember, this was the command we were using to define our app container.
|
To remember, this was the command we were using to define our app container.
|
||||||
|
|
||||||
```bash
|
=== "Unix"
|
||||||
docker run -dp 3000:3000 \
|
```bash
|
||||||
|
docker run -dp 3000:3000 \
|
||||||
-w /app -v "$(pwd):/app" \
|
-w /app -v "$(pwd):/app" \
|
||||||
--network todo-app \
|
--network todo-app \
|
||||||
-e MYSQL_HOST=mysql \
|
-e MYSQL_HOST=mysql \
|
||||||
@ -61,12 +62,12 @@ docker run -dp 3000:3000 \
|
|||||||
-e MYSQL_DB=todos \
|
-e MYSQL_DB=todos \
|
||||||
node:12-alpine \
|
node:12-alpine \
|
||||||
sh -c "yarn install && yarn run dev"
|
sh -c "yarn install && yarn run dev"
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using PowerShell then use this command.
|
=== "Windows"
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
docker run -dp 3000:3000 `
|
docker run -dp 3000:3000 `
|
||||||
-w /app -v "$(pwd):/app" `
|
-w /app -v "$(pwd):/app" `
|
||||||
--network todo-app `
|
--network todo-app `
|
||||||
-e MYSQL_HOST=mysql `
|
-e MYSQL_HOST=mysql `
|
||||||
@ -75,7 +76,7 @@ docker run -dp 3000:3000 `
|
|||||||
-e MYSQL_DB=todos `
|
-e MYSQL_DB=todos `
|
||||||
node:12-alpine `
|
node:12-alpine `
|
||||||
sh -c "yarn install && yarn run dev"
|
sh -c "yarn install && yarn run dev"
|
||||||
```
|
```
|
||||||
|
|
||||||
1. First, let's define the service entry and the image for the container. We can pick any name for the service.
|
1. First, let's define the service entry and the image for the container. We can pick any name for the service.
|
||||||
The name will automatically become a network alias, which will be useful when defining our MySQL service.
|
The name will automatically become a network alias, which will be useful when defining our MySQL service.
|
||||||
@ -161,25 +162,27 @@ docker run -dp 3000:3000 `
|
|||||||
|
|
||||||
Now, it's time to define the MySQL service. The command that we used for that container was the following:
|
Now, it's time to define the MySQL service. The command that we used for that container was the following:
|
||||||
|
|
||||||
```bash
|
=== "Unix"
|
||||||
docker run -d \
|
|
||||||
|
```bash
|
||||||
|
docker run -d \
|
||||||
--network todo-app --network-alias mysql \
|
--network todo-app --network-alias mysql \
|
||||||
-v todo-mysql-data:/var/lib/mysql \
|
-v todo-mysql-data:/var/lib/mysql \
|
||||||
-e MYSQL_ROOT_PASSWORD=secret \
|
-e MYSQL_ROOT_PASSWORD=secret \
|
||||||
-e MYSQL_DATABASE=todos \
|
-e MYSQL_DATABASE=todos \
|
||||||
mysql:5.7
|
mysql:5.7
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using PowerShell then use this command.
|
=== "Windows"
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
docker run -d `
|
docker run -d `
|
||||||
--network todo-app --network-alias mysql `
|
--network todo-app --network-alias mysql `
|
||||||
-v todo-mysql-data:/var/lib/mysql `
|
-v todo-mysql-data:/var/lib/mysql `
|
||||||
-e MYSQL_ROOT_PASSWORD=secret `
|
-e MYSQL_ROOT_PASSWORD=secret `
|
||||||
-e MYSQL_DATABASE=todos `
|
-e MYSQL_DATABASE=todos `
|
||||||
mysql:5.7
|
mysql:5.7
|
||||||
```
|
```
|
||||||
|
|
||||||
1. We will first define the new service and name it `mysql` so it automatically gets the network alias. We'll
|
1. We will first define the new service and name it `mysql` so it automatically gets the network alias. We'll
|
||||||
go ahead and specify the image to use as well.
|
go ahead and specify the image to use as well.
|
||||||
|
Loading…
Reference in New Issue
Block a user