Home > Net >  Connect with FTP to Docker Container
Connect with FTP to Docker Container

Time:02-28

I'm new to Docker and I'm using this Microsoft SQL Server Docker Image

sudo docker pull mcr.microsoft.com/mssql/server:2019-latest

I've run the container on my linux server with this command which is from the microsoft doc:

    sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" \
    -p 1433:1433 --name sql1 --hostname sql1 \ 
   -d mcr.microsoft.com/mssql/server:2019-latest

I can connect with ssh when I'm on my server with this command:

sudo docker exec -it sql1 "bash"

My problem is that I can't figure out how I can connect to this container with FTP.

I thought installing ftp on the image and then run with something like:

sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" \
    -p 1433:1433 -p 21:21 --name sql1 --hostname sql1 \ 
   -d mcr.microsoft.com/mssql/server:2019-latest

But I can't run it again without removing the image. I Would be glad if someone could help me.

CodePudding user response:

I did not found a way to get an FTP Access but the main purpose was to be able to move a file from the host into the container.

The way to do that is as simple as a ssh cp

sudo docker cp foo.txt containerID:/foo.txt

Thanks for the answers

CodePudding user response:

You are not editing the image but the container that you create with that command.

sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" \
    -p 1433:1433 -p 21:21 --name sql1 --hostname sql1 \ 
   -d mcr.microsoft.com/mssql/server:2019-latest

Just run that command to create your container and use that container via

docker start sql1

and

sudo docker exec -it sql1 "bash"

and if you want to have an image of your container after you edited your Container, use the

docker commit sql1

or so. (You might read the documentation on docker commit for correct syntax.)

UPDATE:

As of the comments below, I'd like to recommend you to get yourself confident with the docker file usage instead of docker commit.

  • Related